A CI pipeline should turn a reviewed source revision into an image that can be identified, tested, and promoted. Rebuilding separately for each environment can produce different artifacts even when the source revision is the same.
Make builds traceable
Use lockfiles and deterministic build inputs where possible. Tag the image with a commit or release identifier and record the resulting digest. Pin base-image updates through a deliberate process rather than relying on a mutable
latestRun unit and integration checks before publishing. Scan the image and its dependencies, but make findings actionable with ownership and update paths. Build multi-architecture images only when the deployment targets require them, and verify each architecture. Use build cache for speed without skipping steps that validate changed inputs.
Promote the same artifact
Push a candidate image, deploy it to a test environment, and verify startup, health, logs, and a representative request. Promote the same digest to production after approval. A rollback should point to a previously known-good digest, not rebuild an old commit with today’s mutable dependencies.
Monitor deployment errors and preserve the prior version until the new one is healthy. Document how to inspect the running image digest. CI has done its job when a release can be traced from commit to artifact to deployment and reversed without guesswork.
Deploy the build that CI actually checked
A local image ID identifies the image in the build environment. A registry digest identifies the published content that another machine will pull. Capture the published digest after pushing, then test and deploy the artifact identified by that digest. Assign readable tags for discoverability, and retain the previous digest so operators can select the previous release deliberately. Docker image digests
Use build stages to keep toolchains and credentials out of the runtime image. Where a build genuinely needs a credential, use a BuildKit secret mount rather than an ARG or ENV assignment that can persist in image history or metadata. Check startup and health on the built image and verify any migration requirements alongside it. Docker multi-stage builds · Docker build secrets
Worked example
Run against a reviewed Dockerfile in a test checkout. Record the image identifier in the release artifact; building successfully does not establish runtime health or authorize deployment.
shdocker build --tag example-web:review . docker image inspect example-web:review --format '{{.Id}}'




Community
Discussion(1)
Loading comments…