Multi-stage lets the final image carry ONLY the runtime files (compiled wheel, app code), not the build toolchain (gcc, headers, build tools). Smaller images mean faster pulls, smaller attack surface, and cheaper caching. The build stage uses a heavy base; the runtime stage uses a slim one.
Stage 1 (builder): install gcc, pip install into a venv folder.
Stage 2 (runtime): COPY —from=builder the venv + app code, run as non-root USER appuser.
Install CPU-only torch first (smaller), THEN requirements.txt (avoid the CUDA build).
builder: full toolchain -> /install
runtime: slim base + COPY --from=builder /install + app code
Image size: ~1.2 GB -> ~400 MB
Multi-stage saves GB of image size and dozens of CVEs. Make it the default.