File size: 876 Bytes
937b2c0
 
 
 
 
 
fe2db02
 
 
 
ead1873
 
2f0ed7b
 
ead1873
937b2c0
 
 
ead1873
937b2c0
 
fe2db02
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Use the official Python 3.9 slim image
FROM python:3.9-slim

# Set the working directory inside the container
WORKDIR /code

# Create a directory for the model cache and make it world-writable.
# This ensures that the non-root user running the app can write to it,
# without needing to know the user's name during the build.
RUN mkdir /code/cache && chmod 777 /code/cache

# Set the HF_HOME environment variable to point to our new cache directory.
ENV HF_HOME /code/cache

# Copy the requirements file and install dependencies
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Copy the application code
COPY ./main.py /code/main.py

# Command to run the FastAPI server.
# The Hugging Face platform will run this command as a non-root user.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]