File size: 1,199 Bytes
49f1143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0efb56f
49f1143
 
 
 
 
 
 
 
 
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 a lightweight Python base image
FROM python:3.10-slim

# Set the working directory in the container
WORKDIR /app

# Set environment variable for Python to not buffer stdout/stderr
ENV PYTHONUNBUFFERED=1

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

# Copy the rest of your application code into the container
COPY . .

# Expose the port the app will run on
# Hugging Face Spaces will map this internal port to an external one
EXPOSE 7860

# Command to run the application using Gunicorn and Uvicorn workers
# HF Spaces provides the port via the PORT environment variable
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:7860"]
# Note: Some HF Space configurations might require binding to a port provided by $PORT env var.
# If the above CMD doesn't work, try:
# CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:$PORT"]
# ... but check HF Spaces docs for their standard port handling in Docker templates.
# Port 7860 is the common default in many HF Spaces templates. Let's stick with 7860 for the CMD for now.