FROM python:3.10-slim # System deps for Pillow (libjpeg, zlib) + curl for healthcheck. RUN apt-get update && apt-get install -y --no-install-recommends \ libjpeg-dev \ zlib1g-dev \ curl \ && rm -rf /var/lib/apt/lists/* # HF Spaces require a non-root user with $HOME=/home/user. RUN useradd -m -u 1000 user USER user ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Install Python deps first so they cache across code changes. COPY --chown=user requirements.txt requirements.txt RUN pip install --no-cache-dir --user -r requirements.txt # Copy the rest of the app. COPY --chown=user . . # HF Spaces routes external traffic to port 7860 inside the container. EXPOSE 7860 # Bind to 0.0.0.0 so HF's proxy can reach us. Disable Gradio's analytics # (it tries to phone home and slows boot). ORACLES_FORCE_MOCK is left # unset so the app uses the real Modal LLM when the secrets are present. ENV GRADIO_SERVER_NAME=0.0.0.0 \ GRADIO_SERVER_PORT=7860 \ GRADIO_ANALYTICS_ENABLED=False \ PYTHONUNBUFFERED=1 \ ORACLES_VISUAL_MODE=lean CMD ["python", "app.py"]