Jofthomas HF staff commited on
Commit
e4eb15d
·
1 Parent(s): 1209356

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -25
Dockerfile CHANGED
@@ -1,11 +1,20 @@
1
  FROM python:3.10.9
2
 
3
- # Create a non-root user and group with a specified UID and GID
4
- RUN addgroup --gid 1001 appgroup && adduser --uid 1001 --gid 1001 --disabled-password --gecos "" appuser
 
 
 
 
5
 
6
- # Create directories with appropriate permissions and change ownership
7
- RUN mkdir -m 777 /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR /home/appuser/.local /home/appuser/.cache /home/appuser/tts_models
8
- RUN chown -R appuser:appgroup /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR /home/appuser/.local /home/appuser/.cache /home/appuser/tts_models
 
 
 
 
 
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"]