Skip to content
GitAudience

Upgrade to a new release

.md

Move a self-hosted GitAudience to a new release with Docker Compose, follow the database migrations and go back if needed.

An upgrade replaces the image of the three services. The migrate service updates the database first; api and worker start on the new release only once it has finished.

Know when a release is out

The footer of the sidebar shows the running version, as v followed by the version number. When a newer release exists, Update available appears next to it and opens the release notes on GitHub, at github.com/pierre-b/gitaudience/releases.

The worker checks for a new release once a day, at 5:00 UTC, through GitHub’s releases API. The request carries no identifier: neither your domain nor the instance’s name. Set RELEASE_CHECK_ENABLED=false to turn the check off; you then follow releases on GitHub yourself.

Only the latest minor release is supported. Read the release notes of every release between yours and the new one: a release that needs a change on your side says so there.

Back up

Run backup.sh and keep the dump with a copy of .env, as Backups shows. Going back across a database change needs this backup.

Upgrade with Docker Compose

The release you run is the tag in GITAUDIENCE_IMAGE, in .env. From the directory that holds compose.yaml:

# In .env: GITAUDIENCE_IMAGE=ghcr.io/pierre-b/gitaudience:<new version>
docker compose pull
docker compose up -d

docker compose pull downloads the new image while the old one keeps running. docker compose up -d then stops the old containers and starts the new ones. The worker gets up to 30 seconds to finish the jobs under way before it stops.

If the release notes ship a new compose.yaml, replace yours with it and copy over any change you made. Your .env stays as it is.

What happens at startup

  1. migrate takes a lock, so two runs never apply the same migration twice.
  2. It applies each migration the database doesn’t have yet, each in its own transaction, and records it in the table public.schema_migrations.
  3. It exits. Compose starts api and worker only if it exited successfully.
  4. api and worker wait until the last migration of their image is recorded, then serve.

Follow it with:

docker compose logs -f migrate api worker

If a migration fails, migrate exits with an error, and api and worker don’t start: the instance stays down until you fix the cause or go back. migrate also stops, without applying anything, if a migration it already applied has changed since; the message names the migration.

Check the version

Sign in: the sidebar footer shows the new version. Then check that https://<your domain>/health answers {"status":"ok"} and open a project to look at your data.

Going back

GitAudience migrations add before they remove: a column or a table is only dropped in a release after the one that stopped using it. An older image doesn’t refuse a database that a newer one migrated, so the previous release usually starts on it. Set its tag back in GITAUDIENCE_IMAGE and run docker compose up -d.

If that release doesn’t work on the migrated database, or you go back further, restore the backup you took before the upgrade:

  1. Stop the stack and delete its database volume: docker compose down -v.
  2. Set the previous tag in GITAUDIENCE_IMAGE.
  3. Restore the dump, as Restoring shows, with the same SECRET_KEY.

Anything written since the backup is lost.

Existing pre-v1 installations

For an existing pre-v1 installation, stop API and worker and back up the database and old environment file. Keep the existing SECRET_KEY. Use the old migration account password as the new POSTGRES_PASSWORD, remove the old session secret and separate role passwords, and update Compose. Existing volumes are not initialised again. On a dedicated Compose cluster, download deploy/postgres/harden-existing.sh from the release repository and run it as the OS user postgres; it keeps data and the application password and refuses shared clusters. Then explicitly adopt the unchanged migration tag with the new image before restarting:

docker compose exec -T -u postgres postgres sh < deploy/postgres/harden-existing.sh
docker compose run --rm migrate migrate --adopt-init
docker compose up -d

Adapt the script path to your download location. The tag conversion refuses a different SQL hash or ambiguous history. External PostgreSQL instances require equivalent changes by their administrator. Do not delete the data volume. Pending sign-in codes and GitHub callbacks must be restarted; existing sessions remain valid.