File size: 1,172 Bytes
4bd2b44
9b7e41e
0fde338
281abd2
 
d8285c3
281abd2
 
 
 
0fde338
d8285c3
4bd2b44
0fde338
d8285c3
 
 
 
 
 
 
 
 
 
4bd2b44
 
 
 
d8285c3
 
4bd2b44
d8285c3
4bd2b44
0fde338
 
 
 
d8285c3
0fde338
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Use the official Python base image from Docker Hub
FROM python:3.10-slim

# In your Dockerfile

# Install system dependencies (like ffmpeg) as root
RUN apt-get update && apt-get install -y --no-install-recommends \
    ffmpeg \
    aria2 \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user named 'app'
RUN useradd --create-home app

# Set the working directory for the application
WORKDIR /code

# Copy all application files from your project into the container's working directory
COPY . .

# Change the ownership of all files and directories within /code.
# The -R flag is for "recursive," applying this to everything inside /code.
# THIS IS THE KEY FIX: It gives the 'app' user full control of the directory.
RUN chown -R app:app /code

# Switch from the 'root' user to the 'app' user
USER app

# Install Python dependencies for the 'app' user
RUN pip install --no-cache-dir --user -r requirements.txt

# Add the user's local installation directory to the system's PATH
ENV PATH="/home/app/.local/bin:${PATH}"

# Expose the port the app runs on
EXPOSE 7860

# Command to run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]