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
On this page
- Why it matters
- Artifacts and the platforms that take them
- Tags, digests and immutability
- Build once, promote the same digest
- Static bundles: hashed file names
- Check your understanding
- Apply it
- Review prompt
Lessons of App Deployment
- From Source to Deployable Artifact Concept · 15 min
- Configuration and Secrets Across Environments Worked example · 20 min
- Lab: Deploy Behind a Custom Domain with HTTPS and Health Checks Lab · 30 min
- Lab: Preview Deploys, Zero-Downtime Release and Rollback Lab · 30 min
- Example: Pinning and Rolling Back Model and Prompt Versions Worked example · 10 min
- Check: Production Readiness Review Knowledge check · 8 questions
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.
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:
- CI builds the image from a commit, tags it with the SHA, pushes it and records the digest.
- That digest is deployed to staging with staging configuration, and the tests and checks run against it.
- 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:
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#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:078e1f7bacaa478d75f3a177473be08939ec71a96c996f7a00466dbaced0672bThree 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:
{
"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:
"""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")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.pyapp.js -> assets/app.bb562262.js
style.css -> assets/style.7ddccf44.css
app.js -> assets/app.984fa45a.js
style.css -> assets/style.7ddccf44.cssOnly 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
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:
- Build your service's image from a clean commit, with a
sha-<short SHA>tag, a semantic version tag and the two OCI labels. - Push it to the registry your platform pulls from and copy the digest from the push output.
- Start a release record, one JSON file or one row of
RELEASES.mdper 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:
- Which three questions does a versioned, immutable artifact answer, and which three things must stay out of it?
- 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?
- Why is rebuilding a commit for production not the same as promoting the digest that passed staging?
- How do hashed file names let a static bundle be cached for a year without serving stale code after a release?
References
- The Twelve-Factor App: Build, release, run
- The Twelve-Factor App
- FastAPI: Deployment
- OCI Image Format: pre-defined annotation keys
- Docker docs: docker buildx imagetools create
- Docker docs: docker image pull (pull by digest)
- Docker docs: Build attestations
- Semantic Versioning 2.0.0
- Vite: Building for production
- MDN Web Docs: Cache-Control
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.