The path to production
One change passes six stations on its way to users
Source is built into an artefact, which is deployed and runs as a service.
Every change to a piece of software travels the same road. It starts in an editor, where someone changes the source code. The change is committed to a repository, which keeps every version. A build tests it and packages it. The result is an artefact: one versioned file. The artefact is deployed to an environment. And there it runs as a service, which is what users actually reach.
Languages
Something must turn source code into instructions
Compiled languages ship machine code. Interpreted languages ship the source.
A processor cannot run source code. How the translation happens depends on the language. A compiled language is translated once, before it runs, into machine code for one kind of processor. Java and C sharp compile to bytecode, a portable file that a virtual machine runs on any platform. An interpreted language is not built at all. You ship the source, and an interpreter reads it as the program runs.
Dependencies
Most of what you ship was written by someone else
Three packages you chose bring fifteen more. A lock file pins them all.
Almost no software is written from nothing. Here is a small service: the code you wrote. It uses three packages you chose: one to make web requests, one to serve web pages, one to talk to a cloud. Each of those needs packages of its own. Count them, and your three choices have brought in fifteen more.
Dependencies · Going deeper · 1 of 2
Reading a version number
Major may break things. Minor adds. Patch fixes.
Lock files · Going deeper · 2 of 2
Every ecosystem has a manifest, a lock file and a strict install
The manifest is a wish; the lock file is the fact. Build from the lock.
The artefact
Build once, and promote the same artefact
The same artefact runs everywhere. Only configuration changes.
The build produces one artefact, and from then on it is never changed. Here it is: version one point four point two of a service, built from one commit. That exact file runs in development. The same file is promoted to test. And the same file goes to production. What differs between them is configuration, such as which database to use, and that is supplied from outside.
Tags and digests · Going deeper
A tag is a label that can move; a digest names the exact bytes
Deploy by digest: then every environment provably runs the same artefact.
Environments
Each environment answers one question
Development, test, staging, production: each one a gate.
A change does not go straight to users. It passes through environments, and each answers a question. Development: does it work at all? Test: does it pass every automated test? Staging: does it behave under conditions like the real ones? And production, the only environment customers use: are they getting what they need?
Runtime
"It works on my machine" is a runtime mismatch
A program needs its language version and libraries. A container carries them along.
An artefact still needs somewhere to run, and that place must suit it. On the developer's laptop the application sits on a recent library and a recent Python, and it works. The server has an older Python and an older library. The same application fails. The cure is to pack the application together with the exact runtime it needs, as a container image. Then it runs the same on any host.
CPU architecture · Going deeper
An image carries its libraries, not a kernel, and is built for one CPU
An arm64 image on an amd64 server fails with exec format error. Build for both.
Lesson complete
You finished “How software is built and shipped”
Nicely done.