Upgrade Guide¶
Upgrade procedure for Repod running under Docker Compose.
Back up before upgrading
Always run a backup before upgrading, and keep it until the new version has proved itself: it is the only way back if a database migration ran (see Rolling back). See Backup & restore →
Before you start¶
- Check the changelog for breaking changes: Changelog →
- Review migration notes in the release notes for the target version.
- Schedule a maintenance window. The containers restart in about a minute,
but the API answers nothing while a database migration runs. Most
migrations are instant. A migration that builds an index on a large table is
not: the two trigram-index migrations (
0042,0043) kept a demonstration instance (about two million package rows) unavailable for about ten minutes. You can follow it (see Database migrations). - Use the same compose files as at installation. If you started Repod with
overlays (
-f docker-compose.yaml -f docker-compose.tls.yml ...), pass the same-flist to every command below. A baredocker compose up -dwould start the stack without the TLS proxy.
Standard upgrade procedure¶
cd /opt/repod
# Step 1 — Back up data (and keep the archive until the upgrade is validated)
./backup.sh
# Step 2 — Fetch the new version
git fetch origin
git pull origin main
# Step 3 — Rebuild the images
docker compose build
# Step 4 — Recreate the services that changed
docker compose up -d
# Step 5 — Verify startup (the backend becomes "healthy" once migrations are done)
docker compose ps
curl http://localhost:8000/health/live
docker compose up -d recreates only the containers whose image changed, so
docker compose down is not needed. --no-cache is only for a build that picked
up a stale layer: it downloads every base image again, which took more than 30
minutes on a slow link.
The health check answers:
Verify the deployed version¶
Upgrade to a specific version¶
# List available tags
git tag -l | sort -V | tail -10
# Check out the target version
git checkout v2.0.1
# Rebuild and restart
docker compose build
docker compose up -d
Rolling back¶
Going back to an older version does not undo the migrations
Repod applies its database migrations at every start (alembic upgrade
head). Once a newer version has migrated the database, the older code no
longer knows the database's revision and refuses to start. Tested with a
database at revision 0043 and a version without it:
So checking out the previous version is not enough.
If the new version has to be abandoned, restore the backup taken before the upgrade:
cd /opt/repod
# 1. Stop the services
docker compose down
# 2. Return to the previous version
git log --oneline -10
git checkout <previous-tag-or-commit>
# 3. Restore the database and the /repos data from the pre-upgrade backup
# (see "Restore procedure" in Backup & restore)
# 4. Rebuild and restart
docker compose build
docker compose up -d
# 5. Verify
docker compose ps
curl http://localhost:8000/health/live
Anything written after the backup (uploads, decisions, audit entries) is lost with it, which is why the backup must be recent.
Without a backup, you can sometimes undo migrations with the new version still
installed, before going back (each migration of the recent ones has a
downgrade). Do it only if you know the revision to go back to, and test it on a
copy first:
docker compose exec -u appuser -w /app backend python -m alembic history # find the target revision
docker compose exec -u appuser -w /app backend python -m alembic downgrade <revision>
Upgrading environment variables¶
When a new version introduces new environment variables:
- Check the release notes for new or changed variables.
- Review the Environment variables reference →.
- Update
backend.envand/or.envbefore rebuilding:
# Compare your current backend.env to the example
diff backend.env backend.env.example
# Add any new variables with their default values
nano backend.env
Rebuilding the frontend after URL changes¶
If REACT_APP_API_URL or REACT_APP_REPO_URL changed in .env:
React variables are baked into the JavaScript bundle at build time — they do not take effect until the image is rebuilt.
Database migrations¶
Repod applies PostgreSQL schema migrations automatically on startup via
alembic. No manual steps are required under normal circumstances.
Follow the migrations while the backend starts (the container stays unhealthy
until they finish):
docker compose logs -f backend | grep -i "alembic\|migration\|entrypoint"
# "Running upgrade 0042 -> 0043, ..." for each pending migration, then "Migrations OK."
A migration that builds an index on a large table can be followed from the database, for example:
docker exec repod-db psql -U repod -d repod \
-c "SELECT phase, blocks_done, blocks_total FROM pg_stat_progress_create_index;"
Do not stop the backend while it runs: wait for it to finish.
If migrations fail, use the Alembic commands inside the backend container. The
alembic command itself is not on the PATH: run it as a Python module, as the
container's own entrypoint does, and as appuser:
# Current revision
docker compose exec -u appuser -w /app backend python -m alembic current
# Migration history
docker compose exec -u appuser -w /app backend python -m alembic history
# Apply the pending migrations by hand (last resort)
docker compose exec -u appuser -w /app backend python -m alembic upgrade head
Extensions
The index migrations run CREATE EXTENSION IF NOT EXISTS pg_trgm. On an
external PostgreSQL, see
External PostgreSQL for the
privileges it needs.
ClamAV and Grype database updates¶
ClamAV and Grype vulnerability databases are updated automatically — no upgrade action is required: ClamAV by its own updater, Grype by the nightly security synchronisation (and at startup, when the database on disk is no longer valid). A scan never updates the database by itself.
If you want to force an immediate update after an upgrade:
TOKEN=$(curl -s -X POST http://localhost:8000/api/v1/auth/token \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"YourPassword!"}' | jq -r .access_token)
# Force ClamAV update
curl -X POST -H "Authorization: Bearer $TOKEN" \
http://localhost:8000/api/v1/security/clamav/update
# Force a Grype database update. Run it as appuser: `docker exec` defaults to
# root, and files created by root in /repos/grype-db cannot be updated later
# by the backend.
docker compose exec -u appuser backend grype db update
Version-specific migration notes¶
- Releases from the trigram search indexes (
0042,0043): the first start builds indexes on the wholepackagestable and can take several minutes on a large catalogue (see Before you start). The API answers nothing and writes topackagesare blocked until it ends. - v1.0.x → v1.1.x: a new environment variable,
GRYPE_DB_CACHE_DIR(default/repos/grype-db). Add it tobackend.envif you have custom storage paths. The/repos/grype-db/directory is created automatically on first startup.
For every other release, read the changelog first.
Upgrade checklist¶
- Backup completed (
./backup.sh) and kept until the upgrade is validated - Changelog reviewed for breaking changes
- New environment variables added to
backend.env -
git pullorgit checkout <tag>completed - The same
-fcompose files as at installation are used -
docker compose buildsucceeded -
docker compose up -d— all containers running, backendhealthy -
curl http://localhost:8000/health/live→{"alive": true, ...} - Frontend loads correctly in browser
- Login works with admin credentials
- Version number updated in
/healthresponse