Goal
Build reproducible Docker images and tag them in a way that supports rollbacks.
Multi-stage builds (why)
- smaller final image
- faster builds
- fewer runtime dependencies
Tagging strategy (simple and effective)
Use:
- immutable tag: git sha
- optional human tag: release version
- optional moving tag: latest (careful)
Example:
docker build -t myapp:sha-<sha> .
docker tag myapp:sha-<sha> myrepo/myapp:sha-<sha>
docker push myrepo/myapp:sha-<sha>
Reproducibility rules
- pin base image versions
- use
npm cinotnpm installin CI - avoid downloading random binaries at runtime
Next Step
Deploy safely: canary/blue-green, health checks, and rollbacks.