Building & Artifacts
Build tools compile source into reproducible artifacts that are versioned, checksummed and stored in registries. Learn reproducible builds, artifact versioning, container registries and integrity verification so production runs exactly what you built.
What is this?
A build takes source code and turns it into a deployable artifact — a compiled binary, a bundled package or a container image. Reproducible builds produce identical artifacts from identical input. Artifacts are versioned (semantic versions or commit SHAs), verified with checksums and signatures, and stored in registries such as Docker Hub, Amazon ECR or GitHub Container Registry.
Why do you need it?
- Reproducibility means any build, from any machine, at any time, produces the same artifact from the same source.
- Versioning artifacts makes every deployment traceable to the exact code that produced it.
- Checksums and signatures detect corrupted or tampered artifacts before they are deployed.
- Registries give teams one place to store, scan, promote and retrieve immutable artifacts.
- An immutable artifact is the backbone of safe rollbacks — you redeploy the old version, not rebuild it.
Mental model
A bakery stamping each loaf with a batch number
Versioned, signed artifacts
Every loaf (artifact) carries a batch number (version) and is inspected before leaving (checksum). If one batch is bad, you recall exactly that batch and re-bake from the same recipe (source) — you never sell a loaf you did not bake (reproducibility).
How it works
- The build tool resolves dependencies, then compiles or bundles source into a deployable output.
- Build steps are pinned to exact tool and dependency versions so results do not drift over time.
- The artifact is stamped with an identifier — a semantic version, commit SHA or build number.
- A checksum (SHA-256) and optional signature are computed and stored alongside the artifact.
- The artifact is pushed to a registry with the version as its tag, and environments promote that same immutable artifact.
From source through build to a versioned artifact in a registry.
Key commands
docker build -t myapp:1.4.0 .Produce an image artifact with an explicit version tag.
docker tag myapp:1.4.0 ghcr.io/acme/myapp:1.4.0Retag the image for a specific registry repository.
docker push ghcr.io/acme/myapp:1.4.0Upload the artifact to the container registry.
docker image inspect myapp:1.4.0 --format '{{.Digest}}'Show the content-addressed digest of the image.
git tag v1.4.0Mark the source revision that produced the artifact.
Examples
Build and push a versioned, checksummed container image
VERSION=1.4.0docker build -t myapp:$VERSION .docker tag myapp:$VERSION ghcr.io/acme/myapp:$VERSIONsha256sum image.tar > image.tar.sha256docker push ghcr.io/acme/myapp:$VERSION# verify integrity after pulldocker pull ghcr.io/acme/myapp:$VERSIONdocker image inspect ghcr.io/acme/myapp:$VERSION --format '{{.Digest}}'The image is built, tagged with a semantic version, and pushed to a registry. The tag points to a digest (content hash), so consumers can pin by digest to guarantee they run exactly the verified artifact.
In production
- Images are pushed with both a semver tag and the commit SHA so teams can pin deployments to a verified digest.
- Registries with built-in scanning (GHCR, ECR) gate deployments on vulnerability results.
- CI signs images with cosign or Notary so production only accepts signatures from the trusted pipeline.
- Build caches keyed by lockfile hash keep rebuilds fast without sacrificing reproducibility.
- SBOMs generated at build time feed vulnerability management and license compliance.
Best practices
- Pin base images and dependency versions; never build from unpinned latest.
- Tag artifacts with semver plus commit SHA, and treat tags as immutable once released.
- Compute a SHA-256 checksum and signature for every artifact before storage.
- Use digest-pinned references in production so a mutable tag can never change what runs.
- Scan images and dependencies in the build stage, before they reach a registry.
Common mistakes
- Reusing the latest tag for every push, destroying the ability to roll back to an exact artifact.
- Building with unpinned dependencies and getting different binaries days later.
- Ignoring checksums and pulling artifacts over unverified channels.
- Storing build artifacts only on the runner's ephemeral disk where they are lost between runs.
Common issues
image not found / manifest unknown in registryThe tag was never pushed, was deleted, or was overwritten with a different digest.
Re-push the artifact with the exact tag and confirm with docker image inspect before deploying.
Build succeeds locally but the registry refuses the pushAuthentication failed or the repository name does not match the registry account.
Run docker login to the registry and confirm the repository is owned by the authenticated account.
Checksum mismatch after pulling an artifactThe artifact was corrupted in transit or tampered with at rest.
Re-pull, re-verify against the signed checksum, and if it persists, rebuild from source — never deploy a mismatching artifact.
Debugging tips
- Compare image digests of a passing and failing deployment to see if the wrong artifact ran.
- Rebuild from the exact pinned commit and lockfile to prove a flaky build is environmental.
- Check layer caching: a changed cache key silently rebuilds everything and can hide failures.
- Verify registry push by pulling a fresh copy and comparing digests locally.
Interview checkpoint
Hands-on lab
- Create a build definition for a container image
- Build and tag an artifact with a version
- Retag the artifact for a registry repository
- Verify the artifact by digest
Build, Version and Verify a Container Artifact
30 min · intermediate
Quick quiz
Why is an immutable artifact important for rollbacks?
Using the latest tag for releases is a reliable way to know what is deployed.
Which of these best verifies an artifact's integrity after a pull?
Cheat sheet
v1.4.0Semantic version for a releasesha-<40 hex>Commit SHA for traceability<semver>-<sha>Combined tag conventiongit tag v1.4.0Mark the producing revisionsha256sum fileCompute a checksumdocker image inspect --format '{{.Digest}}'Show image digestdocker pull <image>@<digest>Pull an exact imagecosign sign <image>Sign an artifactdocker buildxMulti-platform, cached builds