| FROM python:3.11-slim | |
| # Optional system packages for faster numpy/pandas builds | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Install Python dependencies first to leverage Docker layer caching | |
| COPY api/requirements.txt ./requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY api ./api | |
| # Spaces injects the listening port through the PORT env var | |
| ENV PORT=7860 | |
| # Expose FastAPI via uvicorn | |
| CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"] | |