Setting it up
Upgrading
Which image tags to run, a backup first, the API and the worker together, and the way back.
A release is numbered X.Y.Z: the last number for fixes, the middle one for what is new, the first
for a change that asks something of you, which its release notes say. The API and the worker are
released as a pair, built from one commit, and run as one: the same version for both.
Which version is running
Section titled “Which version is running”Help & support lists the dashboard, the API and every worker answering, each with its version and commit, and marks a worker on another build than the API. Without signing in, the health endpoint says the same of the API:
curl https://contactmesh.example.com/health/live{"status":"Healthy","version":"1.4.2","commit":"…"}The image tags
Section titled “The image tags”| Tag | Names | Changes |
|---|---|---|
1.4.2 | One release | Never |
1.4 | The newest fix of 1.4 | With each fix |
latest | The newest release | With each release |
1.4.2-rc.1 | A candidate for 1.4.2 | Never |
main | The newest development build | With every change; not for running |
Run a release by its full number, 1.4.2, for both images. A tag that moves can move one image before
the other is pulled, and the pair is then two versions.
Upgrading
Section titled “Upgrading”-
Read the release notes for every version between yours and the new one. A first number that changes says what it asks of you there.
-
Write down the newest migration under Database on Help & support. If the upgrade moves it, the way back is a restore, not a tag.
-
Back up the database, and keep the protection key beside the dump. The production stack opens no PostgreSQL port, so the dump comes out through its container:
Terminal window docker compose exec -T postgres \sh -c 'pg_dump --format=custom --no-owner --no-privileges -U "$POSTGRES_USER" "$POSTGRES_DB"' \> /secure/backup/contactmesh-before-1.4.2.dump -
Set both images to the new version in
.env:CONTACTMESH_API_IMAGE=git.kruede.com/lukas/contactmesh-api:1.4.2CONTACTMESH_WORKER_IMAGE=git.kruede.com/lukas/contactmesh-worker:1.4.2 -
Pull both, then start the API before the worker. The worker and the API stop first, so neither runs old code against a schema the migrate step is moving forward; starting the API runs that step first, and the worker starts again once the API answers. PostgreSQL is left alone, and the dashboard is away for the seconds a migration and the API’s restart take.
To check first that both images are the ones ContactMesh published, with cosign and the key the manual serves:
Terminal window curl -fsSLO https://contactmesh.example.com/docs/cosign.pubcosign verify --key cosign.pub git.kruede.com/lukas/contactmesh-api:1.4.2cosign verify --key cosign.pub git.kruede.com/lukas/contactmesh-worker:1.4.2Terminal window docker compose pull api workerdocker compose stop worker apidocker compose up -d --wait apidocker compose up -d worker -
Check Help & support. Every row has the new version, nothing is marked as differing from the API, and Database says Up to date.
./contactmesh update --version 1.4.2 does steps 3 to 6 for you, stopping the worker and the API before
the migrate step moves the database forward and starting them once it has. See
The operator tool.
The migrate step
Section titled “The migrate step”compose.yaml runs the migrations in a container of their own, migrate, before the API and the worker
start, as the database’s owner. Since 1.9.0 it also keeps a database role for the API and the worker,
contactmesh_app, which reads and writes ContactMesh’s data and can change nothing else, once
CONTACTMESH_DB_APP_PASSWORD is set in .env. Without it they log in as the owner, a superuser, as before,
and Help & support marks Database role. To switch, take 1.9.0’s compose.yaml, set the variable to
the output of openssl rand -hex 32, and run docker compose up -d.
docker compose up -d and docker compose up -d api run the step first; --no-deps skips it, and an API
that logs in as the role then waits for it and refuses to start. docker compose ps -a lists it as
exited (0) once it has run. Going back below 1.9.0 takes the older compose.yaml as well as the older
images, and the variable out of .env.
Building from the repository instead of pulling: check out the release’s tag, then build both images with the script, which names the build after the tag.
git fetch --tagsgit checkout v1.4.2scripts/build-images.shdocker compose stop worker apidocker compose up -d --wait apidocker compose up -d workerGoing back
Section titled “Going back”If the newest migration did not change, put the previous version back in .env for both images and run
step 5 again.
If it did, the older version refuses to start against the newer schema, and a tag change is not enough. Stop the API and the worker, restore the dump taken in step 3 with the protection key it was taken with, put the previous version back for both images, and start them. What ContactMesh wrote into mailboxes after the backup is still there, and reconciliation recognises it again. Deploying says what a backup holds and what it needs beside it.