Guide
What you get: You get a multi-stage Dockerfile and .dockerignore: cached dependency layer, production dependencies only, non-root user, HTTP HEALTHCHECK, plus an image-size estimate and how to verify it. Best for Developers containerising a web app for production..
Before you start
- Fill language, start_command and port (we used Node.js 22 + TypeScript built into dist/, node dist/server.js, 3000 with GET /healthz)
- Docker to build and check the image yourself
Worked example (Nov 14, 2026, Claude Code 2.1.318 (claude-opus-5-5); Codex 0.151.0 (gpt-5.6-sol))
Input
bakehouse-api (Express 5 + TypeScript, npm run build -> dist/, GET /healthz).
Result
Claude Code: final stage `gcr.io/distroless/nodejs22-debian12:nonroot`, HEALTHCHECK via Node fetch, allowlist .dockerignore. Codex: final stage `node:22-bookworm-slim` with `USER node`, HEALTHCHECK via Node fetch, denylist .dockerignore.
Neither tool could run Docker in its session; we built and ran both images. Both built, served /healthz, reached Docker health status 'healthy', ran as non-root (uid 65532 / 1000) and contained only express and zod (no typescript, vitest, tsx, oxlint). Sizes: Claude Code 173 MB uncompressed / 54 MB saved (it estimated 135-150 MB / 45-55 MB); Codex 279 MB / 82 MB (it estimated 220-260 MiB / 60-90 MB). Both chown the app files to the runtime user, so the app can modify its own code; not a stated requirement.
How to check it worked
- docker build, then docker run and wait for health status 'healthy'
- docker exec <container> id -u (or node -e 'console.log(process.getuid())' on distroless) should not be 0
- List node_modules in the image: no dev dependencies
Common problems
- curl/wget-based HEALTHCHECK on slim or distroless images that don't have them (both tools avoided this)
- Distroless images have no shell, so `docker exec ... sh` debugging doesn't work
Log in to join the discussion.