FROM python:3.10-slim WORKDIR /app # System deps (for ML libraries) RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ libgthread-2.0-0 \ libglib2.0-0 \ libcairo2 \ libpango-1.0-0 \ libgdk-pixbuf-xlib-2.0-0 \ libffi-dev \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy repo code COPY . . # HF routes traffic to $PORT – bind to it ENV PORT=7860 PYTHONUNBUFFERED=1 # Set environment variables for HF Spaces ENV HF_HOME=/data ENV DATA_ROOT=/data ENV STUB_MODE=0 # Create writable directories and set permissions RUN mkdir -p /data/outputs /data/artifacts && \ chmod 755 /data && \ chmod 755 /data/outputs && \ chmod 755 /data/artifacts # Use ENTRYPOINT instead of CMD to prevent Hugging Face from overriding ENTRYPOINT ["gunicorn", "-w", "1", "-k", "gthread", "-t", "300", "-b", "0.0.0.0:7860", "backend.runner.app:app"]