The same commit built twice produces images with different digests. Why does that matter, and how do you make builds reproducible?
AdvancedScenarioPipelines at scale
Answer
Situation read → If you can't rebuild the same artifact, you can't verify what's running matches the source, and a rebuild for a hotfix may pull in unexpected changes.
What I'd do →
- Pin base images by digest, not tag:
FROM python:3.12-slim@sha256:2f0c...
- Use lockfiles and install from them (
npm ci,pip install --require-hashes,go.sum). - Avoid
apt-get upgradeand unpinned package installs, or pin versions. - Remove timestamps: set
SOURCE_DATE_EPOCHand use BuildKit'srewrite-timestampoption so file times are fixed.
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) docker buildx build \
--output type=image,name=ecr/api:$SHA,push=true,rewrite-timestamp=true .
- Build once and promote the digest anyway, so day-to-day you never depend on rebuilding.
Why → Reproducibility lets you prove an artifact came from a given commit, which is the basis of supply-chain verification.
Interview tip → Even if bit-for-bit reproducibility isn't reached, pinned inputs alone remove most surprises; say that.
More on Pipelines at scale
The CI pipeline takes 45 minutes. Developers want it under 10. How do you approach it?IntermediateYou have a monorepo with 40 services. Every commit builds and tests all of them. How do you fix that?AdvancedFlaky tests fail 1 in 5 runs and developers just click "re-run". How do you fix this culture and the tests?BeginnerYour self-hosted GitHub runners can't keep up at peak and sit idle at night. How do you run them at scale?AdvancedDocker builds in CI take 12 minutes because every runner starts with an empty cache. How do you speed them up?IntermediateHow do you secure the software supply chain from commit to production?Advanced