Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +14 -25
Dockerfile
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
FROM python:3.10.9
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Set environment variables
|
11 |
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
|
@@ -13,24 +22,4 @@ ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
|
|
13 |
ENV HOME=/home/appuser
|
14 |
ENV PATH="/opt/venv/bin:$PATH"
|
15 |
|
16 |
-
# Copy all files to the container
|
17 |
-
COPY . .
|
18 |
-
|
19 |
-
# Set the working directory
|
20 |
-
WORKDIR /
|
21 |
-
|
22 |
-
# Install virtualenv and set up the virtual environment as root
|
23 |
-
RUN python -m venv /opt/venv
|
24 |
-
|
25 |
-
# Change ownership of the virtual environment directory to the non-root user
|
26 |
-
RUN chown -R appuser:appgroup /opt/venv
|
27 |
-
|
28 |
-
# Switch to the non-root user
|
29 |
-
USER appuser
|
30 |
-
|
31 |
-
# Activate the virtual environment and install requirements
|
32 |
-
RUN /opt/venv/bin/pip install --no-cache-dir --upgrade pip && \
|
33 |
-
/opt/venv/bin/pip install --no-cache-dir --upgrade -r /requirements.txt
|
34 |
-
|
35 |
-
# Command to run the application
|
36 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
FROM python:3.10.9
|
2 |
|
3 |
+
WORKDIR /
|
4 |
+
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
RUN apt update && apt install -y ffmpeg
|
9 |
|
10 |
+
RUN useradd -m -u 1000 user
|
11 |
+
USER user
|
12 |
+
ENV HOME=/home/user \
|
13 |
+
PATH=/home/user/.local/bin:$PATH
|
14 |
+
|
15 |
+
WORKDIR $HOME/app
|
16 |
+
|
17 |
+
COPY --chown=user . $HOME/app
|
18 |
|
19 |
# Set environment variables
|
20 |
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
|
|
|
22 |
ENV HOME=/home/appuser
|
23 |
ENV PATH="/opt/venv/bin:$PATH"
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|