# ── Build stage ─────────────────────────────────────────────── FROM python:3.11-slim AS builder WORKDIR /build COPY requirements.txt . RUN pip install --no-cache-dir --prefix=/install -r requirements.txt # ── Runtime stage ───────────────────────────────────────────── FROM python:3.11-slim # HF Spaces runs as a non-root user; create one to match RUN useradd -m -u 1000 appuser WORKDIR /app # Copy installed packages from builder COPY --from=builder /install /usr/local # Copy source code COPY environment/ ./environment/ COPY app.py . # Make inference.py available at root (required by spec) COPY inference.py . # HF Spaces exposes port 7860 EXPOSE 7860 USER appuser ENV PORT=7860 ENV PYTHONUNBUFFERED=1 CMD ["python", "app.py"]