| # Use the official Python 3.11 slim image as a base | |
| FROM python:3.11-slim | |
| # Prevent Python from buffering stdout/stderr (so logs appear immediately) | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set the working directory inside the container | |
| WORKDIR /app | |
| # Copy only requirements first to leverage Docker layer caching | |
| COPY requirements.txt . | |
| # Upgrade pip, install all Python dependencies | |
| RUN pip install --upgrade pip && \ | |
| pip install -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY . . | |
| # Expose port 7860 for Hugging Face Spaces | |
| EXPOSE 7860 | |
| # Run the app on port 7860 (REQUIRED for Hugging Face) | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] |