Update Dockerfile
Browse files- Dockerfile +20 -9
Dockerfile
CHANGED
@@ -1,26 +1,37 @@
|
|
1 |
FROM python:3.10.9
|
2 |
|
3 |
-
|
|
|
4 |
|
5 |
-
|
|
|
6 |
|
7 |
-
|
|
|
8 |
RUN apt update && apt install -y ffmpeg
|
9 |
|
|
|
10 |
RUN useradd -m -u 1000 user
|
11 |
-
|
|
|
12 |
ENV HOME=/home/user \
|
13 |
-
|
14 |
|
|
|
|
|
15 |
WORKDIR $HOME/app
|
16 |
|
|
|
17 |
COPY --chown=user . $HOME/app
|
18 |
|
19 |
-
#
|
|
|
|
|
|
|
20 |
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
|
21 |
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
|
22 |
-
ENV HOME=/home/
|
23 |
ENV PATH="/opt/venv/bin:$PATH"
|
24 |
-
RUN chmod -R 777 /home/user
|
25 |
|
26 |
-
|
|
|
|
1 |
FROM python:3.10.9
|
2 |
|
3 |
+
# Use a more secure method for setting the working directory
|
4 |
+
WORKDIR /app
|
5 |
|
6 |
+
# Copy the requirements file
|
7 |
+
COPY ./requirements.txt /app/requirements.txt
|
8 |
|
9 |
+
# Install dependencies
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
11 |
RUN apt update && apt install -y ffmpeg
|
12 |
|
13 |
+
# Add and configure the user
|
14 |
RUN useradd -m -u 1000 user
|
15 |
+
|
16 |
+
# Set environment variables for the user
|
17 |
ENV HOME=/home/user \
|
18 |
+
PATH=/home/user/.local/bin:$PATH
|
19 |
|
20 |
+
# Set the user and working directory
|
21 |
+
USER user
|
22 |
WORKDIR $HOME/app
|
23 |
|
24 |
+
# Copy the application code
|
25 |
COPY --chown=user . $HOME/app
|
26 |
|
27 |
+
# Ensure the user has the correct permissions
|
28 |
+
RUN chmod -R 777 $HOME/app
|
29 |
+
|
30 |
+
# Set additional environment variables
|
31 |
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
|
32 |
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
|
33 |
+
ENV HOME=/home/user
|
34 |
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
35 |
|
36 |
+
# Set the command to run the application
|
37 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|