# Build stage - includes pip for installing dependencies FROM cgr.dev/chainguard/python:latest-dev AS builder WORKDIR /app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt --user # Runtime stage - minimal production image FROM cgr.dev/chainguard/python:latest WORKDIR /app # Copy installed packages from builder COPY --from=builder /home/nonroot/.local/lib/python3.*/site-packages /home/nonroot/.local/lib/python3.13/site-packages COPY --from=builder /home/nonroot/.local/bin /home/nonroot/.local/bin # Copy application code COPY app.py ./ COPY public ./public EXPOSE 9431 # Chainguard images run as nonroot user by default ENV PATH="/home/nonroot/.local/bin:$PATH" ENV PYTHONPATH="/home/nonroot/.local/lib/python3.13/site-packages:$PYTHONPATH" CMD ["-m", "gunicorn", "-w", "4", "-b", "0.0.0.0:9431", "app:app"]