FROM python:3.12-slim-bookworm WORKDIR /app # Install system deps: supervisor (runs both services), gcc (native extensions for xgboost/shap) RUN apt-get update && \ apt-get install -y --no-install-recommends supervisor gcc && \ rm -rf /var/lib/apt/lists/* # Install only what's needed for the deployed app (no mlflow, no psycopg, no training deps) COPY requirements-spaces.txt ./ RUN pip install --no-cache-dir -r requirements-spaces.txt # Copy source, pre-populated SQLite DB, and serialized models COPY src/ src/ COPY data/olist.db data/olist.db COPY models/ models/ # Supervisor config COPY docker/spaces/supervisord.conf /etc/supervisor/conf.d/supervisord.conf ENV PYTHONPATH=/app/src ENV DATABASE_URL=sqlite:////app/data/olist.db ENV FASTAPI_URL=http://localhost:8000 # HuggingFace Spaces requires port 7860 EXPOSE 7860 CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/conf.d/supervisord.conf"]