Build, deploy and release
Table of contents
Introduction
Your product reaches production through three commands. product:build compiles it, product:deploy runs it on this machine, and product:release publishes a version for everyone else. A server that only runs the product needs none of them, since a clone of the repository starts with docker compose.
splent product:build
splent product:deploy
Build and deploy never leave your machine. Release sends things out, and it is the only one you cannot undo.
Building and deploying
SPLENT_IMAGE in deploy/.env names another.Build checks the product, writes the bundle deploy/ and the pins the image is built from, and builds the image. Deploy writes deploy/.env, asks for the secrets and starts the <product>_deploy project.
To put a change into production, run both again, or product:derive --prod, which does both. Commit what the build changed, since a server deploys what the repository says.
Deploying from a clone
git clone <the product's repository> && cd <product>/deploy
cp .env.example .env # then fill in the required values
docker compose up -d
.env.example gives every setting a working default except the secrets, which are empty and marked required. docker compose up starts nothing until each one is set. Choose the database passwords before the first start, since MariaDB keeps the ones it starts with.
| Your releases publish an image | They do not | |
|---|---|---|
| The web service runs | <forge host>/<org>/<product>:stable |
<product>:<version> |
| The image is built | By the release. The host pulls it | On the host, on the first up, from PyPI at the pinned versions |
| To upgrade | git pull, docker compose pull, docker compose up -d |
git pull, docker compose up -d --build |
The database and uploads live on named volumes, so they survive upgrades, and the app applies its migrations when it starts.
To hold a server on one version, set SPLENT_IMAGE=<image>:<version> in .env. To build instead of pulling, run docker compose -f docker-compose.yml -f docker-compose.build.yml up -d --build.
Releasing a version
splent product:release
product:release first refuses a release a clone could not deploy, such as a product that does not validate, a pin nobody published, or a .gitignore that leaves out the bundle. Then it runs lint and tests, bumps the version, commits the bundle, and publishes to PyPI, the forge and the image registries.
If a step fails, release:resume finishes the rest without bumping the version again. A release deploys nothing, unless your product has a feature that deploys it.
Which one to run
| You want to | Run |
|---|---|
| Put a change into production on this machine | product:build, then product:deploy |
| The same, in one command | product:derive --prod |
| Check that the production image builds | product:build |
| Regenerate the deploy files without the image | product:build --no-image |
| Stop production | product:deploy --down |
| Publish a version | product:release |
| Run a released version on a host without SPLENT | git clone, then docker compose up -d in deploy/ |
| Run another image for one deploy | product:deploy --image <ref> |
| Finish a release that stopped halfway | release:resume product:<name> |
| Release a feature | feature:release |
Reference
product:build |
product:deploy |
product:release |
|
|---|---|---|---|
| Reads | The product’s pyproject.toml and docker/, and each feature’s docker/ at its pin |
deploy/ and the image it names |
The product’s repository, plus what build reads |
| Writes | deploy/, the runtime pins, docker/requirements.lock, splent.contracts.json, docker/spl/, and the image <product>:<version> |
deploy/.env and the <product>_deploy containers |
A release commit and a tag |
| Sends out | Nothing | Nothing | The tag and release page to the forge, the package to PyPI, the image to the registries |
| Needs | Every production feature pinned to a published version | A previous build | A valid product, every feature pinned, lint and tests passing, credentials |
| Undo | Run it again | product:deploy --down |
None. A PyPI version is permanent |
See also
product:build,product:deployandproduct:release, every file and rule- Continuous delivery, the release channel and automatic deployment
- Editable and pinned features, why production takes pinned features only
- Env files, where each variable of
deploy/.env.examplecomes from - Features that run a server, how a feature’s containers reach the deploy stack
- Tutorial 5, Release and deploy, the whole flow step by step