File size: 1,020 Bytes
b5b6a8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use an official Python runtime as a parent image
FROM python:3.10-slim

# Set the working directory in the container
WORKDIR /code

# Set the Hugging Face cache directory to a writable location
ENV HF_HOME=/tmp/.cache/huggingface

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

# Install any needed packages specified in requirements.txt
# --no-cache-dir: Disables the cache to keep the image size smaller
# --upgrade: Ensures pip is up to date
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Copy the rest of the application's code into the container at /code
COPY . /code

# Expose the port the app will run on. Hugging Face Spaces uses 7860.
EXPOSE 7860

# Command to run the app when the container launches.
# Uvicorn is the server that runs our FastAPI app.
# --host 0.0.0.0 makes the app accessible from outside the container.
# --port 7860 matches the exposed port.
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]