# syntax=docker/dockerfile:1
# Multi-stage, the same shape as cloud-01 (illustrated/7-mlops/docker-buildx-arm.html): a
# builder stage carries the compiler toolchain some wheels need, and a slim runtime stage
# copies out only the installed packages — the toolchain never reaches the shipped image.
FROM python:3.12-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
    && rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt

FROM python:3.12-slim AS runtime
RUN useradd --create-home --uid 1000 appuser
WORKDIR /app
COPY --from=builder /install /usr/local
COPY src/ ./src/
ENV PYTHONPATH=/app/src
USER appuser
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "askapi.main:app", "--host", "0.0.0.0", "--port", "8000"]
