From code to running software
Last updated
Pila's code is merged and tested. But code on main doesn't give anyone a queue number: it has to be built, packaged, put on a computer that's always on, and started. In this lesson you'll follow a change from Marco's laptop to the screen in the waiting room, meet servers and the cloud in plain words, and see why “it works on my machine” is the oldest excuse in software.
By the end of this lesson you can
- Describe the steps between a merge and running software: build, package, deploy, run
- Explain what a server, hosting and the cloud are, in plain words
- Explain why software that works on one computer can fail on another, and what containers do about it
Code isn’t software yet
Merged code is text in a repository. Before a patient can use it, four things have to happen:
| Step | What happens | In Pila |
|---|---|---|
| Build | Turn the source into something runnable, and check it | Install dependencies, run ruff and the tests |
| Package | Bundle it with everything it needs | One image: Pila, its libraries, and Python itself |
| Deploy | Put the package where it will run | Copy it to the server and switch over |
| Run | Keep it running and watch it | Restart it if it stops; watch its signals (lesson 7.7) |
The Twelve-Factor App, a short guide written by engineers at the hosting company Heroku, makes the same point: keep build, release and run as separate stages, so the thing you tested is exactly the thing that runs.
A change’s journey
When the steps are automated, a change goes from merge to patients in minutes. This is the road Stage 7 builds for Pila:
- 9:02 Merged
main on the hosting site.0 of 6 placed right
Install the dependency versions in the lock file
Run the tests
Copy the new image to the server
Switch from the old version to the new one
Restart Pila if it crashes
Check every minute that Pila still answers
Servers, hosting and the cloud
A server is a computer that runs software for other people and is always on. It usually has no screen; people reach it over the network. Pila's server receives texts from the gateway and serves the counter page and the waiting-room screen.
Where does the server live?
- On site: a computer in the health centre's back room. Cheap at first, but it stops when the power or internet does, and someone has to look after it.
- Hosting: a company runs the computers in a data centre, with backup power and fast internet, and rents them out.
- The cloud: hosting where you rent computing by the hour and get more in minutes, managed through a website or code. “The cloud” is still someone else's computers.
Pila's team chooses hosting in a Philippine data centre: patient data stays in the country, which makes the Data Privacy Act questions in lesson 9.2 simpler.
“It works on my machine”
Jun's laptop has Python 3.14, the dependencies he installed last month, and a setting he changed and forgot. The server has none of that. A program that works on one computer can fail on another because of anything it quietly relies on: a version, a file, a setting, the time zone.
Three habits close the gap:
- Pin dependencies with a lock file (lesson 5.7), so every computer installs the same versions.
- Build on a clean computer, not a developer's laptop, so nothing forgotten sneaks in. Lesson 7.2's build server does this on every push.
- Package everything together. A container image holds the app, its libraries and a small operating system, so it runs the same on a laptop, a test server and the real one. Docker is the best-known tool for building and running them.
Spot the trap: copying files by hand
Until now, Jun has released Pila by connecting to the server, copying the changed files across, and restarting it. It takes him about forty minutes and a checklist he keeps in his head.
What happens if…
Check what you learned
Sources
Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.
- The Twelve-Factor App: build, release and run as separate stages, and other habits for running apps
- Docker Docs: What is Docker?: containers and images, from the tool’s own documentation
- Martin Fowler: Deployment Pipeline: the automated road from commit to production
- Python Packaging User Guide: An Overview of Packaging for Python: the ways a Python program can be packaged to run elsewhere