examples icon indicating copy to clipboard operation
examples copied to clipboard

feat(docker): add Dockerfile.11_final_v2 with hardened, reproducible …

Open PatrykQuantumNomad opened this issue 2 months ago • 0 comments

Hi, I'm watching more videos and having more fun. I've added a version that is closer to my prod version.

This commit introduces Dockerfile.11_final_v2, a fully optimized, secure, and deterministic multi‑stage build for the FastAPI service.

Key improvements and changes:

  • Uses pinned digest base images (python:bookworm@sha256 and slim@sha256) for deterministic, reproducible builds.
  • Introduces Tini as PID 1 for proper signal forwarding and process reaping.
  • Builds dependencies via Astral UV for faster, locked, and cached installs.
  • Enforces non‑root numeric user (UID/GID 10000) for runtime safety.
  • Moves all DB and secret configuration to runtime environment variables instead of build‑time arguments.
  • Integrates a lightweight docker-entrypoint.sh for dynamic env expansion and clean signal handling.
  • Sets strict runtime hardening: --read-only, --tmpfs /tmp, --cap-drop=ALL, --security-opt no-new-privileges:true.
  • Adds OCI metadata labels (build date, revision, description) for traceability.
  • Supports reproducible dependency manifest (dependencies.txt) for auditability.
  • Enables healthcheck route compatibility with configurable APP_PORT.

PatrykQuantumNomad avatar Nov 09 '25 19:11 PatrykQuantumNomad