| # Use slim Python base image | |
| FROM python:3.11-slim | |
| # Prevent Python from writing pyc files | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies required for shap & xgboost | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| gcc \ | |
| g++ \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first (for layer caching) | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy project files | |
| COPY . . | |
| # Expose port expected by HF Spaces | |
| EXPOSE 7860 | |
| # Start FastAPI with uvicorn | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |