Write production-grade Dockerfiles
Multi-stage builds, slim bases, layer-order discipline, and non-root runtime for small secure images.
Track: ☁️ DevOps & Cloud · Domain: Containers · Level: intermediate · ~30 min
Who this is for: DevOps Engineers, SREs, Cloud Architects, Platform Engineers
When to Use This Skill
Multi-stage builds, slim bases, layer-order discipline, and non-root runtime for small secure images. Use it whenever a matching task appears in conversation — the agent loads these instructions on demand.
Steps
- Start from slim/distroless variants pinned by digest, not :latest
- Order layers least-to-most volatile; lock dependency manifests first
- Multi-stage: build artifacts in builder, copy ONLY runtime needs
- Run as non-root USER; expose no debug ports by default
- Add HEALTHCHECK matching your orchestration's probe
- Scan images in CI; fail on critical CVEs with a waiver process
Common Pitfalls
- Copying node_modules across stages including dev deps
- apt-get upgrade layers busting cache every build
Success Signals
- Image size under 200MB typical service
- Zero critical CVEs shipped
Commands
Install with skills CLI
npx skills add aniruddhaadak80/skills --skill containers-dockerfile-production
Install globally
npx skills add aniruddhaadak80/skills --skill containers-dockerfile-production -g
Part of aniruddhaadak80/skills · Browse all at https://skills.sh/aniruddhaadak80/skills