FROM python:3.10

WORKDIR /app

COPY . .

RUN --mount=target=/tmp/packages.txt,source=packages.txt 	apt-get update && 	xargs -r -a /tmp/packages.txt apt-get install -y && 	apt-get install -y curl && 	curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && 	apt-get install -y nodejs && 	rm -rf /var/lib/apt/lists/* && apt-get clean
RUN ln -s /usr/lib/python3/dist-packages/uno.py /usr/local/lib/python3.10/site-packages/
RUN ln -s /usr/lib/python3/dist-packages/unohelper.py /usr/local/lib/python3.10/site-packages/

RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user
# Set home to the user's home directory
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app

CMD ["python","app.py"]