File size: 1,361 Bytes
689bd3a
 
 
 
 
 
 
 
 
 
 
 
 
 
37ba690
689bd3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /code

# Copy the dependencies file to the working directory
COPY ./requirements.txt /code/requirements.txt

# Install any needed dependencies specified in requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Copy the rest of the application code to the working directory
COPY ./app.py /code/app.py
# .env file will be handled by docker-compose for local dev, or secrets in HF

# Make port 8000 available to the world outside this container
# Hugging Face Spaces expects the app to listen on port 7860 by default for Docker,
# but we can configure it. Let's stick to 8000 as defined in app.py and uvicorn command.
# If HF requires 7860, we'll need to adjust the uvicorn command and EXPOSE.
# Let's keep 8000 for now and check HF docs if issues arise. Or we can make it 7860 explicitly.
# Let's change to 7860 to be safe with HF defaults.
EXPOSE 7860

# Define environment variable for the port (optional, uvicorn command specifies it)
# ENV PORT=7860

# Run app.py when the container launches using uvicorn
# Use 0.0.0.0 to ensure it's accessible from outside the container
# Change port to 7860 to match Hugging Face Docker convention
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]