File size: 907 Bytes
df6c762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f3a579
751c45f
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
FROM python:3.11

# Set the working directory
WORKDIR /code

# Copy the requirements file into the container
COPY ./requirements.txt /code/requirements.txt

# Install the Python dependencies
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Create a non-root user (user ID 1000) as required by Hugging Face Spaces
RUN useradd -m -u 1000 user

# Switch to the new non-root user
USER user

# Define environment variables for the user path
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Change the working directory to the user's home
WORKDIR $HOME/app

# Copy the rest of the application files to the container with correct permissions
COPY --chown=user . $HOME/app

# Run the FastAPI application on port 7860 using Uvicorn with 4 workers for high concurrency
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "6"]