| # Use an official Python runtime as a parent image | |
| FROM python:3.9-slim-buster | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Install any needed packages specified in requirements.txt | |
| # First, copy just the requirements.txt to leverage Docker cache | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY . . | |
| # Expose port 7860 as requested by the user for Hugging Face Spaces | |
| EXPOSE 7860 | |
| # Command to run the application | |
| # Use Uvicorn to run FastAPI, binding to 0.0.0.0 and the exposed port | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |