Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 6 · Concept · 15 min · revision 2

From Source to Deployable Artifact

What a deployable artifact is and which platforms take which kind; how tags, digests and pinned inputs make a container image traceable and immutable; why you build once and promote the same digest; and how hashed file names version a static bundle.

Contentsand lesson path

What you will learn

  • Package a service or web app as a versioned, immutable artifact (for example a container image or a static bundle) for a target platform.

Prerequisites: Containerization

01. Why it matters

So far in this track you have run code straight from a working copy: uvicorn main:app in a folder on your laptop. That cannot answer three questions that every production service must be able to answer at any moment:

  • What exactly is running? Not "roughly main from Tuesday", but one build of one commit.
  • Is it the same everywhere? Staging and production, and every instance in production, should run identical bytes, so that a test result in one place tells you something about the other.
  • Can we get back? When a release misbehaves, the previous version must be ready to run again within minutes, without rebuilding anything.

A deployable artifact answers all three. It is the built, self-contained output of one commit: everything the platform needs to run the service except configuration and secrets, which arrive from the environment when the process starts (the next lesson covers them). The Twelve-Factor App calls this the build stage and keeps it strictly apart from the release stage (an artifact combined with one environment's configuration) and the run stage. This lesson is about producing artifacts you can name, trust and move between environments unchanged.

02. Artifacts and the platforms that take them

The shape of the artifact depends on where it will run:

  • Container image, for container services (Google Cloud Run, Amazon ECS with Fargate, Azure Container Apps, Kubernetes) and most platform-as-a-service hosts, such as Fly.io and Render. The notes API ships as an image built from a Dockerfile like the one in the containerization skill.
  • Function package, a zip file of code and dependencies or a container image, for serverless platforms such as AWS Lambda.
  • Static bundle, a folder of HTML, CSS, JavaScript and assets from a bundler, for static and edge hosts such as Cloudflare Pages, Netlify and Vercel, or object storage behind a CDN.

Platforms that build from your repository still create an artifact behind the scenes, and the same rules apply to it: know which commit it came from, never change it in place, keep the previous one.

Every artifact leaves out three things: configuration that differs between environments, secrets, and large, changing data such as model weights or a vector index, which live in a volume, an object store or a model registry, with versions of their own.

03. Tags, digests and immutability

A container registry stores each image under a digest: sha256: followed by a hash of the image manifest, which in turn lists the hashes of every layer. Change one byte anywhere and the digest changes, so a digest names exactly one image, for ever. A tag is a readable pointer to a digest, and anyone with push rights can move it to another one. latest is nothing more than the tag Docker applies when you do not give one.

Give every build two tags and record its digest:

Three references to one image (digest shortened)
localhost:5000/notes-api:sha-57cc811   names the commit the image was built from
localhost:5000/notes-api:1.1.0         names the release, as a semantic version
localhost:5000/notes-api@sha256:078e…  names the exact bytes; it can never move
  • The Git SHA tag makes the image traceable in both directions, from a running container to its source and from a commit to its image. The OCI labels org.opencontainers.image.revision and org.opencontainers.image.version record the same inside the image.
  • The semantic version (MAJOR.MINOR.PATCH) is what release notes and incident channels use, and it signals the size of a change.
  • The digest is what you deploy. Given notes-api@sha256:…, a platform pulls exactly that content, even if someone later pushes another image under the same tag.

Treat released tags as immutable: never push new content as 1.1.0; release 1.1.1 instead. Many registries can enforce this, for example Amazon ECR's tag immutability setting.

Pin the inputs of a build too. FROM python:3.12-slim gets whatever that tag points to on build day, and an unpinned pip install fastapi gets the newest release. Pin the base image by digest and dependencies by exact version or a lock file with hashes, and two builds of one commit come out nearly identical; Docker also attaches a provenance attestation recording what each pushed image was built from. Nearly is not identical, which is why the next rule exists.

04. Build once, promote the same digest

Rebuilding a commit for production gives you a new, untested artifact: the base image behind a tag, a transitive dependency or the build tooling may have changed since the staging build. So a pipeline builds each release once and then promotes it:

  1. CI builds the image from a commit, tags it with the SHA, pushes it and records the digest.
  2. That digest is deployed to staging with staging configuration, and the tests and checks run against it.
  3. If staging passes, the same digest is deployed to production with production configuration.

Adding a release tag to an image that is already in the registry needs no rebuild and not even a pull. docker buildx imagetools create writes a new tag that points at an existing digest:

Terminal
DIGEST=sha256:078e1f7bacaa478d75f3a177473be08939ec71a96c996f7a00466dbaced0672b
docker buildx imagetools create --tag localhost:5000/notes-api:prod \
  "localhost:5000/notes-api@$DIGEST"
for tag in 1.1.0 sha-57cc811 prod; do
  printf '%-13s' "$tag"
  docker buildx imagetools inspect "localhost:5000/notes-api:$tag" \
    --format '{{.Manifest.Digest}}'
  echo
done
Illustrative output (the push lines are shortened; your digest and SHA differ)
#1 [internal] pushing localhost:5000/notes-api
#1 0.030 pushing sha256:078e1f7bacaa… to localhost:5000/notes-api:prod
#1 DONE 0.0s
1.1.0        sha256:078e1f7bacaa478d75f3a177473be08939ec71a96c996f7a00466dbaced0672b
sha-57cc811  sha256:078e1f7bacaa478d75f3a177473be08939ec71a96c996f7a00466dbaced0672b
prod         sha256:078e1f7bacaa478d75f3a177473be08939ec71a96c996f7a00466dbaced0672b

Three names, one image. The registry here is the local one from the labs in lessons 3 and 4; with a cloud registry the commands are the same.

Configuration is the only thing that differs between environments. Images built from pull-request branches for preview deployments are for review only and are never promoted; the release is built once from the merged commit. Rollback also becomes simple: deploy the previous digest again. That works only if the registry still holds it, so make sure any clean-up policy keeps at least the last few releases.

Keep a short record of every release, as a file in the repository, a CI artifact or your platform's deploy history. In an incident it is the first thing you need:

JSON · releases/1.1.0.json (illustrative)
{
  "version": "1.1.0",
  "git_sha": "57cc811",
  "image": "localhost:5000/notes-api@sha256:078e1f7bacaa478d…",
  "base_image": "python:3.12-slim@sha256:a6e34c598f24…",
  "built_at": "2026-10-19T14:29:31Z",
  "deployed": {"staging": "2026-10-19T14:30:09Z", "prod": "2026-10-20T09:05:00Z"}
}

05. Static bundles: hashed file names

Static hosts and CDNs cache files aggressively, which creates a versioning problem of its own: after a release, a browser can combine the new index.html with yesterday's cached app.js. Bundlers solve this by putting a hash of each file's content into its name; Vite, for example, writes files such as dist/assets/index-<hash>.js. This short script shows the mechanism:

Python · build_static.py
"""Copy static files into dist/ under content-hashed names; rewrite index.html."""

import hashlib
import shutil
from pathlib import Path

src, dist = Path("site"), Path("dist")
shutil.rmtree(dist, ignore_errors=True)
(dist / "assets").mkdir(parents=True)
html = (src / "index.html").read_text(encoding="utf-8")
for path in sorted(src.glob("*")):
    if path.suffix not in {".css", ".js"}:
        continue
    digest = hashlib.sha256(path.read_bytes()).hexdigest()[:8]
    hashed = f"assets/{path.stem}.{digest}{path.suffix}"
    shutil.copy(path, dist / hashed)
    html = html.replace(f'"{path.name}"', f'"{hashed}"')
    print(f"{path.name:<10} -> {hashed}")
(dist / "index.html").write_text(html, encoding="utf-8")
Terminal
mkdir -p site
printf '<link rel="stylesheet" href="style.css">\n<script src="app.js"></script>\n' \
  > site/index.html
printf 'body { font-family: system-ui; }\n' > site/style.css
printf 'document.title = "Notes";\n' > site/app.js
python build_static.py
printf 'document.title = "My notes";\n' > site/app.js  # change one file
python build_static.py
Expected output
app.js     -> assets/app.bb562262.js
style.css  -> assets/style.7ddccf44.css
app.js     -> assets/app.984fa45a.js
style.css  -> assets/style.7ddccf44.css

Only the file that changed got a new name. That lets each part of the bundle have its own caching rule:

  • assets/*: Cache-Control: public, max-age=31536000, immutable. A hashed name will never hold different content, so browsers and CDNs may keep it for a year.
  • index.html: Cache-Control: no-cache, so clients revalidate it on every visit and always learn the current hashed names.

The whole dist/ folder is the artifact. Static and edge hosts keep every deployment as an immutable snapshot with its own ID, so rolling back means pointing the domain at the previous snapshot, which takes seconds.

06. Check your understanding

Practice check · 3 questions

Artifacts, tags and digests

Three questions about what goes into an artifact and how you name it.

Q1. Which reference is guaranteed to give you the same image bytes next month?
Q2. The notes API loads a 3 GB search index that a job rebuilds every night. Where should the index live?
Q3. Your bundler emits assets/app.<hash>.js, yet after a release some users run the old code for a day. What is the most likely cause?
Practice only: not graded, not saved, not evidence.

07. Apply it

Start this skill's practice project. Choose the managed platform you will deploy to and note which kind of artifact it accepts. Then:

  1. Build your service's image from a clean commit, with a sha-<short SHA> tag, a semantic version tag and the two OCI labels.
  2. Push it to the registry your platform pulls from and copy the digest from the push output.
  3. Start a release record, one JSON file or one row of RELEASES.md per release, with the version, SHA, image digest and base image digest.

If the project has a web front end, check that its asset names contain hashes and that index.html is not cached for long. The lab in lesson 3 walks through each command.

08. Review prompt

Without looking back, answer in your own words:

  1. Which three questions does a versioned, immutable artifact answer, and which three things must stay out of it?
  2. What is the difference between a tag and a digest, which one do you deploy, and why give an image both a SHA tag and a semantic version?
  3. Why is rebuilding a commit for production not the same as promoting the digest that passed staging?
  4. How do hashed file names let a static bundle be cached for a year without serving stale code after a release?

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check