Chrunos commited on
Commit
726a1c2
·
verified ·
1 Parent(s): c9fb766

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -20
Dockerfile CHANGED
@@ -1,29 +1,26 @@
1
- # Use the official lightweight Python image.
2
- FROM python:3.10
3
 
4
- # Set the working directory to /app
5
- WORKDIR /app
 
 
 
6
 
7
- # Create a non-root user with an explicit UID
8
- RUN adduser -u 1000 --disabled-password --gecos "" appuser && chown -R appuser /app
9
- USER appuser
10
 
11
- # CRITICAL FIX: Add the user's local bin directory to PATH so the shell can find 'uvicorn'
12
- ENV PATH="/home/appuser/.local/bin:$PATH"
13
 
14
- # Copy the requirements file
15
- COPY --chown=appuser requirements.txt .
16
-
17
- # Install the dependencies
18
- # Note: As a non-root user, pip will default to --user install, putting files in ~/.local
19
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
 
21
- # Copy the rest of the application code
22
- COPY --chown=appuser . .
23
 
24
- # Expose the port
25
  EXPOSE 7860
26
 
27
- # Command to run the application
28
- # Using 'python -m uvicorn' is safer than just 'uvicorn' to ensure it uses the installed module
29
- CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
 
4
+ # Set up a new user 'user' with UID 1000
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+ ENV HOME=/home/user \
8
+ PATH=/home/user/.local/bin:$PATH
9
 
10
+ # Set the working directory to /home/user/app
11
+ WORKDIR $HOME/app
 
12
 
13
+ # Copy the current directory contents into the container at /home/user/app
14
+ COPY --chown=user . .
15
 
16
+ # Install dependencies
 
 
 
 
17
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
18
 
19
+ # Create a directory for yt-dlp cache
20
+ RUN mkdir -p /tmp/.yt-dlp-cache && chmod 777 /tmp/.yt-dlp-cache
21
 
22
+ # Expose port 7860
23
  EXPOSE 7860
24
 
25
+ # Start the application using uvicorn pointing to the ASGI-wrapped 'app' object
26
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]