# ── Build stage ─────────────────────────────────────────────────────────────── FROM python:3.11-slim AS builder WORKDIR /app # Install build dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir --prefix=/install -r requirements.txt # ── Runtime stage ───────────────────────────────────────────────────────────── FROM python:3.11-slim # Hugging Face Spaces expects the app to run as a non-root user RUN useradd -m -u 1000 appuser WORKDIR /app # Copy installed packages COPY --from=builder /install /usr/local # Copy application code COPY --chown=appuser:appuser . . # Ensure sub-packages are importable RUN touch tasks/__init__.py graders/__init__.py agents/__init__.py USER appuser # HF Spaces expects port 7860 EXPOSE 7860 ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/app CMD ["python", "-m", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]