FROM python:3.11-slim # System deps for matplotlib, OR-Tools, and general build RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # HF Spaces requires running as non-root user with UID 1000 RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /home/user/app # Install Python deps first (for Docker layer caching) COPY --chown=user requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy app files, data, and pre-computed artifacts COPY --chown=user . . # Streamlit must listen on 0.0.0.0:7860 for HF Spaces EXPOSE 7860 CMD ["streamlit", "run", "app.py", \ "--server.port=7860", \ "--server.address=0.0.0.0", \ "--server.headless=true", \ "--server.enableCORS=false", \ "--server.enableXsrfProtection=false", \ "--browser.gatherUsageStats=false"]