- Go 69%
- JavaScript 14.6%
- Python 7.5%
- Shell 6.3%
- CSS 2.4%
- Other 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Adding a watch for an RSS or Atom feed stopped after the lookup: the page showed what was found (for a GitHub releases.atom link, both the feed and the repository) but never the options or Start watching. The feeds plugin's only mode has no options, and plugin.Mode leaves an empty params list out of its JSON, so the add form's md.params.map() threw. LookupMode now always sends params, and the form's field helpers take missing fields as none. Switching between two plugins or two modes then threw as well: the redraw read the "when to check" fields after replacing them. It reads them first now and keeps the choice. The mock serves a forge release feed that both plugins read, and e2e looks it up. Fixes #1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019agRhSTd2VxHrQ2ogmewLt |
||
| .forgejo/workflows | ||
| cmd/belfry | ||
| docs | ||
| hack | ||
| internal | ||
| plugins | ||
| presets | ||
| web | ||
| .dockerignore | ||
| .editorconfig | ||
| .env.example | ||
| .gitignore | ||
| CLAUDE.md | ||
| compose.yml | ||
| docker-entrypoint.sh | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| plan.md | ||
| progress.md | ||
| README.md | ||
Belfry
Keeps your compose stacks a controlled distance behind latest.
Belfry watches the image registries behind every service in your compose stacks, decides which version each tracked service should be on (newest, pinned, or N releases behind), and applies updates in a maintenance window. If the updated service doesn't come up healthy, Belfry rolls it back and tells you.
It reaches your stacks through Portainer's own API, or straight from a Docker host: the Docker socket (ideally behind a socket proxy) plus your compose files. It runs as one container with a web UI. Through Portainer it needs no Docker socket at all.
Belfry can also watch projects you don't run, or don't run yet: paste a link to a GitHub, Forgejo, Gitea or GitLab repository and get notified of new releases, tags or pushes to a branch. Plugins add what it can watch, and anyone can write one.
More screenshots: service drawer, policies, update history, watches, plugins, notifications, Portainer instances, Docker hosts, settings and sign-in.
What it does
- Discovers every compose stack in every Portainer environment, service by
service, with the running image digest. Add as many Portainer instances as
you run, and choose per instance whether Belfry manages all of its
environments (Docker hosts), including ones added later, or only the ones
you pick. Docker hosts Portainer doesn't manage can be added directly: each
compose project becomes a stack, and standalone containers (
docker run) are listed too. - Tracks versions per service with three strategies:
- Stay N behind — sort every tag that matches the service's filter, newest
first, and target the N-th one.
behind 1on Nextcloud means "run the second-newest release". - Follow newest — target the newest matching tag, or a new digest for
floating tags like
:latest. - Pinned — never change it, just show what's available.
- Stay N behind — sort every tag that matches the service's filter, newest
first, and target the N-th one.
- Steps majors one at a time (default on) so apps that only migrate one major version per upgrade, like Nextcloud, walk 29 → 30 → 31 across windows instead of jumping and breaking.
- Schedules a global maintenance window (cron) with per-service overrides, and checks registries every few hours.
- Applies updates through Portainer: fetches the stored stack file, changes
exactly one
image:line (or one stack environment variable when the tag is${VAR}), and redeploys with "pull image". Everything else in your compose file is left byte-for-byte as you wrote it. On a Docker host Belfry makes the same one-line change in the compose file on disk (or the.envfile), then pulls the image and recreates the container through the Docker API (see Docker hosts). - Verifies and rolls back: the service must come up on the new image, stay up without restarting (a crash loop is caught by Docker's restart count, not missed between probes), be healthy if it has a healthcheck, answer its HTTP check if it has one, and log nothing fatal. With a preset it must also say it is ready, on the version the tag names. On failure Belfry redeploys the previous definition (on a Docker host: puts the old container and file back) and holds the service until you clear the error (see How an update runs).
- Follows upgrade paths: presets for MySQL, MariaDB, PostgreSQL and Nextcloud know how each upgrades (MySQL 8.0 → 8.4 → 9.7, one LTS at a time; PostgreSQL majors never automatically), and a window walks the whole path one verified step after another (see Upgrade paths and presets).
- Backs databases up first: a dump, a copy of the data directory, or both, before every update of a database its preset knows, with a restore button (see Database backups).
- Watches an update before it counts, and asks you when its logs look wrong without being clearly broken: keep it or roll it back from the app, or from ntfy's buttons (see Decisions). An AI can be asked to read those logs too (AI log review).
- Notifies on Discord and ntfy, plus an in-app inbox: when a new version is detected (with the planned window), when approval is needed, when an update succeeds, and when one fails and is rolled back. The inbox also follows each update while it runs and links to its progress, and updates itself and the unread count without a page refresh. On Discord each update is one message that moves through its steps to its result (see Notifications).
- Optional approval gate per service. Updates lists every planned update at the top, with its window and whether it waits for approval, so you can approve, run or cancel it there.
- Optional image cleanup per service: after a successful update, delete the image it replaced and any other leftover images of that repository. Docker keeps any image a container still uses, so nothing in use is lost.
- Named policies bundle those rules (strategy, major steps, schedule, approval, image cleanup) so a group of services shares them: change the policy and every service that follows it changes too. The dashboard links each such service to its policy, and its own rules are greyed out while it follows one. Saving a policy is instant: its services are re-checked in the background (from the cached tag lists, and only when a rule that moves targets changed), with a progress bar in the sidebar and on the policy.
- Release notes and security advisories for the images it updates: the notes of every release between what runs and the planned version, and a warning when a published advisory affects the version you run (see Release notes and security).
- Watches follow projects by link and notify when something new turns up (see Watches and plugins).
- Backup: export settings, policies, connections, service rules, plugins and watches to one file, with secrets optionally encrypted under a passphrase, and import it with a preview of every change.
- Login with a local account created on first run, plus optional single sign-on through any OIDC provider (Authentik, Authelia, Keycloak…).
Quick start
services:
belfry:
image: git.pandanas.net/code-liberation-front/belfry:latest # or build: .
restart: unless-stopped
ports: ["8080:8080"]
environment:
TZ: America/New_York
PORTAINER_URL: https://portainer.local:9443
PORTAINER_API_KEY: ptr_xxxxxxxx
PORTAINER_INSECURE_SKIP_VERIFY: "true"
volumes:
- belfry-data:/data
volumes:
belfry-data:
- In Portainer, create an access token for a user that can edit your stacks (My account → Access tokens).
- Start Belfry, open http://host:8080, create the admin account.
- The dashboard fills in after the first check. For each service you want managed, open it and tick Track this service.
Belfry runs as uid/gid 1000 (PUID/PGID to change it). The container starts
as root only to give /data to that user, so a bind-mounted host directory
works without a manual chown. On NFS with root_squash that chown can't
happen; chown the export on the server instead.
Everything in the environment block can also be set later in Settings;
environment variables only seed the settings on first start. PORTAINER_URL
becomes the first Portainer instance. Add more under Settings → Connections,
where each instance lists its environments so you can pick which ones Belfry
manages. Upgrading from a version with one Portainer moves its connection
into an instance automatically.
If a connection can't be reached at a check, the dashboard says so, and its services stay as Belfry last saw them; the others carry on.
Docker hosts
For a host Portainer doesn't manage, add a Docker host under Settings →
Connections (or set DOCKER_HOST for the first one). Belfry needs two
things:
- The Docker API. Mount the socket, or point Belfry at a socket proxy
such as
tecnativa/docker-socket-proxywithCONTAINERS=1 IMAGES=1 NETWORKS=1 INFO=1 POST=1(addresstcp://docker-proxy:2375). The socket gives root on the host, so a proxy is the safer choice. With the socket mounted, the entrypoint keeps the socket's group when it drops toPUID, so nogroup_addis needed. - Your compose files, read and written by Belfry. Containers record the
path of the compose file that created them, so mount the stacks folder at
the same path, or tell the connection where it is mounted ("Folder on the
host"
/opt/stacks, "Same folder inside Belfry"/stacks). Belfry writes them asPUID, so that user needs write access.
services:
belfry:
image: git.pandanas.net/code-liberation-front/belfry:latest
restart: unless-stopped
ports: ["8080:8080"]
environment:
TZ: America/New_York
DOCKER_HOST: unix:///var/run/docker.sock
volumes:
- belfry-data:/data
- /var/run/docker.sock:/var/run/docker.sock
- /opt/stacks:/opt/stacks # same path as on the host
volumes:
belfry-data:
An update to a compose service changes its one image: line (or its
variable in .env) on disk first, so the file stays the source of truth and
the next docker compose up doesn't put the old version back. Belfry then
pulls the new image and recreates the container with the same settings,
networks, ports and volumes (anonymous volumes included). It drops only what
the old image supplied, such as its environment defaults and command, so the
new image's own apply. The old container is kept, stopped and renamed, until
the update holds; a rollback removes the new one and starts the old one
again. Standalone containers have no file and are recreated the same way.
A compose service is listed but never updated (with the reason in its
drawer) when Belfry can't read or write its compose file, when the file
names a different image than the container runs (edited without an up),
when its image variable is also used outside image lines or isn't in .env,
or when other containers share its network (network_mode: service:…).
Belfry also leaves its own container alone. A host that Portainer manages is
better added through Portainer.
If your stacks use :latest today
Most do. A floating tag has no version, so Belfry can't compute "one behind"
until it knows what you're actually running. Services on :latest show as
Unpinned, and Belfry matches the running image's digest against the newest
version tags to propose the concrete one (e.g. nextcloud:latest → 32.0.4).
Click Adopt and track to accept it. Nothing is redeployed at that point;
the concrete tag is written into your stack file on the first real update.
Plain version tags are tried first, since that is what :latest almost
always is, so an image with many variants per release (caddy has eight)
isn't matched to the wrong one.
A tag can only be adopted if it has an image for the platform the service
runs on (linux/amd64, say, read from the running image): caddy's
2.11.8-nanoserver-ltsc2025 is Windows-only, so it can't be what a Linux
host runs. A service adopted that way before Belfry checked shows as
Unpinned again with the reason; adopt the right version and its tag
filter follows the new one.
Belfry builds a tag filter from the adopted tag so only its siblings count as
versions: 32.0.4 → ^\d+\.\d+\.\d+$, 10.10.3ubu2404-ls55 →
^\d+\.\d+\.\d+ubu\d+-ls\d+$. You can edit the filter per service.
Watches and plugins
A watch follows one project and tells you when it has something new. Open
Watches → Add a watch, paste a link and choose Look it up. Belfry asks
every installed plugin what is behind the link. Once one has read it, choose
what to be told about and when to check: every so often (hourly by default,
at most every 5 minutes), or on a schedule, such as every Wednesday at
8:00 in the container's TZ. A scheduled watch that was down at its time
checks as soon as Belfry is back; one whose check fails tries again every 15
minutes until it works.
- New releases, optionally including pre-releases
- Pushes to a branch, defaulting to the repository's default branch
- New tags, optionally only those matching a regular expression
The first check only notes what is already there, so a new watch never sends you the project's history. After that, each check that finds something new sends one notification, for example "immich-app/immich: v3.4.0" or "Belfry: 3 new commits". It shows in the in-app inbox with a link to the release or commit, and also goes to Discord and ntfy unless you turn that off under Settings → Notifications. If a working watch starts failing, Belfry tells you once and keeps trying.
Belfry doesn't know about any kind of project by itself; plugins teach it.
Plugins lists the store: the catalog in this repository
(plugins/index.json), plus the plugins built into the
binary, which install offline.
| Plugin | Watches |
|---|---|
| Git repositories | Releases, tags and pushes on GitHub, Forgejo, Gitea, Codeberg and GitLab, including self-hosted ones, and security advisories on GitHub. Private repositories take a read-only access token, which is only sent to that site. A GitHub token in the plugin's settings raises GitHub's limit of 60 requests an hour. It also provides the release notes and advisories of the images Belfry updates. |
| RSS and Atom feeds | New entries in any RSS or Atom feed. Paste the feed, or a page that links to one (a blog, a project's news). |
| Packages | New versions on npm, PyPI and crates.io, optionally including pre-releases. npm is read from its dist-tags (latest, next…), so a release nobody tagged isn't seen. |
| Docker Hub images | New tags of any image, including ones you don't run yet. |
| JSON Feed | New posts in any JSON Feed. |
Plugins can also be installed from a link or an uploaded file. Belfry shows what a plugin follows and which sites it contacts before installing it.
Most plugins are one JSON file that describes the requests to make; Belfry
runs them, so the file holds no code. A plugin that needs real logic runs as
its own small service instead:
plugins/examples/web-page is an example that
watches a web page for changes. docs/PLUGINS.md is the
guide for writing either kind, and belfry plugin try runs a plugin against
a link while you write it.
Release notes and security
Belfry reads where each image's code lives from its
org.opencontainers.image.source label, which most images built on GitHub,
GitLab or Forgejo carry. A service's drawer shows it under Release notes
and security. When the image doesn't name one (official Docker Hub images
often don't), enter the project's repository there, for example
https://github.com/nextcloud/server. What you enter wins over the label,
and it is part of the config export.
With the Git repositories plugin installed:
- Release notes: the drawer lists every release after the running
version up to the planned one (or the newest, when nothing is planned),
each with its notes. Updates → Planned has a Release notes button
for each planned update. Versions are matched by number, so a release
v32.0.3goes with the tag32.0.3-apache. - Security advisories: at each check (at most every six hours per repository) Belfry reads the advisories the project publishes on GitHub and compares their affected versions with what you run. The dashboard marks an affected service, the drawer lists each advisory with its severity and whether the planned update fixes it, and Planned says when an update fixes one. Every advisory that newly affects a running version is announced once, in one notification per check. Settings → Notifications decides whether that also goes to Discord and ntfy.
Published ranges are often open-ended (Valkey's "≥ 7.2", fixed in 7.2.9,
8.0.3 and 8.1.1), so Belfry also reads the fixed versions: a version at or
past the fix on its own release line, or newer than every fix, isn't
affected. A tag that names a whole line, like 9.1, is compared as 9.1.0;
the message then says the fix may already be in a fresh pull of it.
Advisories only cover what maintainers publish in their GitHub repository
(Vaultwarden and Immich do; Nextcloud publishes elsewhere), so no advisory
listed doesn't mean no vulnerability. Forgejo, Gitea and GitLab have no
public advisories API. A plugin can add other sources: any plugin with a mode
whose role is releases or advisories is used the same way (see
docs/PLUGINS.md).
None of this changes what Belfry updates or when.
Backup and moving to a new server
Settings → Backup → Download config saves settings, policies, connections, each service's update rules (and the repository you entered for it), installed plugins and watches to a JSON file. Accounts and update history aren't in it.
Secrets (Portainer API keys, the Discord webhook, tokens) are left out unless you tick Include secrets and choose a passphrase. They are then encrypted with AES-256-GCM under a key derived from the passphrase (PBKDF2-SHA256, 600,000 rounds), and the rest of the file stays readable.
Import always shows what would change first: what is added, what changes (with old and new values), what is already the same and what is skipped, and why. Items match by name. A service matches by connection, environment, stack and service name, so it is found again on a new server. Matching items are updated, new ones added, and nothing is deleted. Without the passphrase, everything but the secrets is imported and the secrets already set stay as they are. Services on a connection the file adds are matched once Belfry has read that connection, which the import does first.
Notifications
Everything shows in the in-app inbox. Discord and ntfy get what Settings → Notifications picks, as cards:
- Update planned: running and planned version, when (a Discord timestamp, so everyone reads it in their own time zone), the rules it follows, and links to the service and its release notes. If a newer build lands before the window, the same message is edited instead of a new one posted (within a day; after that a change gets a new message, since Discord doesn't alert anyone to an edit).
- Each update is one message, posted when it starts and edited at every step (🟩🟩🟨⬜) until it says Updated, Rolled back (with the reason and where it failed) or Failed. ntfy, which can't edit, only gets the result.
- Security: one card per affected service, coloured by the worst advisory still open, with the advisories that need you apart from the ones the planned update fixes, each linking to the advisory.
- Approvals and what watches find get their own cards.
For images on a floating tag like :latest, messages show the version the
image's org.opencontainers.image.version label names (latest 15.6.1 →
15.6.2) with the digests, rather than "latest → latest".
Belfry's address (Settings → Notifications, or BELFRY_BASE_URL) lets
messages link into Belfry: the service, the update's log, the approval.
Without it they link to the project instead.
Digests (a checkbox there) replace the message per planned update and per update with two: after each check, what the coming windows will update (edited while the next window stays the same), and when a window's updates are over, what happened. Failures still get their own message.
How an update runs
- At a maintenance window, every tracked service whose target differs from what's running is queued (one at a time, so a stack of ten doesn't restart everything at once).
- Belfry fetches the stack file and env from Portainer, computes the change,
and PUTs the stack back with
pullImage: true. Portainer runs the compose redeploy; only services whose definition changed get recreated. On a Docker host, Belfry pulls the image, edits the file and recreates the service's containers itself (and those sharing a changed variable). - For a database whose preset knows how (see Database backups), Belfry first backs it up from the old container. Nothing is changed unless the backup completed.
- Belfry polls the service's container every 5 s: it must be on the new
image, running, healthy if it has a healthcheck, answer its HTTP check
(drawer → Checks after an update) and stay that way for 60 s (Settings →
Update safety; a preset can ask for longer). A container still on the
old image 90 s after the redeploy returned was never replaced (Portainer
accepts a stack whose new image then fails to pull), so the wait ends
there and says so, rather than at the timeout. A restart of its container
(Docker's
RestartCountgoing up, or a newStartedAt) ends the wait at once: with a restart policy a crash-looping container is back up within a fraction of a second, so it looks "running" at nearly every probe. Being killed for memory does too. When the image comes from a stack variable that other services use too (Immich's server and machine-learning shareIMMICH_VERSION), those move to the new version with it, and must come up on it healthy as well. Siblings that were running before must still be running. - Then its logs are read. Every line is reduced to a signature (numbers,
addresses, IDs and timestamps taken out) and compared with what the old
container logged in its last 30 minutes and in its first 5 minutes after
it started: its normal noise. Many apps log the same harmless errors at
every start (SearXNG's engines that need Tor, say), and a container up
for days has none of those in its recent logs. A line matching
a fatal pattern (
panic:,FATAL,Segmentation fault,exec format error, a Python traceback, plus a preset's own, such as MySQL's[ERROR] … Aborting) that the old version never logged fails the update. An error-level line that is new, or five times as frequent (and at least 10 times), makes it suspect: you decide (see Decisions). A preset can also require a readiness line (MySQL'sready for connections) before the timeout, and a version marker that has to match the target (Version: '8.4.6'for tag8.4). The lines that decided it are kept with the update as evidence and quoted in its notification. - Services that depend on it (
depends_on, directly or through another service) and were running are then restarted, so they reconnect to the new version, and must come back running and healthy. Updating Immich's redis restarts immich-server, for example. Preview change lists both kinds of service before you update. - With a watch (Settings → Update safety, 10 minutes by default), it is then watched: its restarts and logs are checked every 30 s, and a fatal line or a restart rolls it back. The old container (or stack file) is kept until the watch ends, so a rollback is still exact. Other updates go on meanwhile, except on the same stack, which waits.
- On failure (or after the health timeout, 120 s by default), Belfry PUTs the original file and env back (on a Docker host: restores the file and puts the old containers back), waits for it to settle (restarting dependents again), and sends an error notification. The service is held until you clear the error in its drawer, so a bad release isn't retried every night.
- With image cleanup on, Belfry then deletes the old image through the Docker API (never forced: an image some container still uses is kept and logged).
Log on an update under Updates shows these steps (which one it is on, live, while it runs) above its text log. A queued or running update also has a notification that links there; when the update finishes, that notification becomes the result. Preview change in a service's drawer shows the exact diff before you click Update now.
If Belfry is stopped mid-update, it can't know how far the update got, so on
the next start that run is marked failed and the service is held like any other
failed update. Queued runs are picked up again, and so are updates being
watched or waiting for a decision: what their rollback needs (the original
stack file and env, or the replaced containers) is kept encrypted in the
database with a key in the data folder (secret.key), and their deadlines
stay as they were.
Open pages get changes pushed over a Server-Sent Events stream
(/api/events). Behind a reverse proxy, make sure it doesn't buffer responses
for that path (Belfry sends X-Accel-Buffering: no for nginx).
Rolling back the image doesn't roll back data the new version already upgraded: MySQL 8.0 can't open a data directory 8.4 upgraded, and Nextcloud refuses to run on data newer than itself. A preset knows the log lines that say such an upgrade started. When an update fails after one, Belfry puts back the copy of the data it took before (when it took one) and then the old image; without a copy it doesn't roll back at all, holds the service and sends an urgent message naming the backup, for you to restore it (see Restoring a backup). If the new version refused before touching the data (MySQL 9.7 refusing an 8.0 directory), the image rollback is safe and happens as usual.
Decisions
An update whose logs show new errors but nothing fatal waits for you, 30 minutes by default (Settings → Update safety). It is up on the new version meanwhile, with the old container kept. Under Updates it shows the lines, a countdown and two buttons, Keep this version and Roll back now; the same is in its notification. On Discord it gets a message of its own (an edit wouldn't alert anyone), edited to who decided once someone has. With Belfry's address set, the ntfy notification has the two buttons too: each is a link signed for that update and action, that works until the deadline and only while the update still waits.
With no answer by the deadline the default applies: roll it back (the default), keep it, or leave it and keep asking. A database that already upgraded its data is only rolled back with a copy of its data to put back. While an update on a connection waits for a decision, the window starts nothing more on that connection.
Upgrade paths and presets
Some software can't skip versions. MySQL upgrades one LTS at a time (8.0 → 8.4 → 9.7): 9.7 refuses an 8.0 data directory, though 8 → 9 is "one major". Nextcloud has to be on the newest release of a major before the next one. Two rules handle that:
- Finish the major first (a rule of a service or policy): a new major is entered only from the newest release line of the current one. On 8.0.40 with 8.4.6 out, the target is 8.4.6 even though 9.7 exists; on 8.4.6, 9.7 is next.
- Stops (from a preset): release lines the path has to visit in order.
Presets are built in (presets/*.json, format in
docs/PRESETS.md) and matched on the image's repository:
| Preset | Images | Upgrade path | Logs | Backup |
|---|---|---|---|---|
| MySQL | mysql, mysql/mysql-server, Oracle's community-server |
finish the major, stops 8.0 → 8.4 → 9.7 | ready line, version, refused/aborted upgrades, data upgrade markers | mysqldump |
| MariaDB | mariadb |
finish the major | ready line, version, aborts, mariadb-upgrade markers |
mariadb-dump |
| PostgreSQL | postgres |
minor releases only: a new major needs pg_upgrade, so it is announced, never applied |
ready line, incompatible data directory, PANIC |
pg_dumpall |
| Nextcloud | nextcloud |
finish the major | data newer than the image, upgrade markers; suggests the HTTP check /status.php with "maintenance":false |
A preset only fills defaults: Finish the major first set to No on a service or policy turns its path off, and the reason for a capped target says which preset capped it.
A window goes on along the path: once 8.0 → 8.4 went through and checked out, 8.4 → 9.7 is queued right away, each step verified and rolled back on its own. Belfry tells you each time it continues (Settings → Update safety turns this off; then the next step waits for the next window). An update started by hand does one step.
Database backups
For MySQL, MariaDB and PostgreSQL, Belfry backs the database up before every update (drawer → Backups; on by default for these images):
- A dump (the default): the image's own tool (
mysqldump --all-databases --single-transaction --routines --events --triggers,mariadb-dump,pg_dumpall) runs in the old container while it still serves, streamed through gzip to the backup folder. It counts only if the tool exited 0, the dump ends with its completion line and holds more than a header, and the disk had room (twice the last backup). Otherwise the update stops before anything changed. - A copy of the data: the container is stopped, its data directory
(
/var/lib/mysql, …) copied out, and started again: downtime for about the length of the copy. This is what lets Belfry roll back automatically after the database started upgrading its data. - Both.
The credentials come from the container's environment
(MYSQL_ROOT_PASSWORD, MARIADB_ROOT_PASSWORD, POSTGRES_USER/_PASSWORD,
or a *_FILE secret read from inside the container), unless you enter a user
and password in the drawer (needed with MYSQL_RANDOM_ROOT_PASSWORD). The
password is passed in the command's environment (MYSQL_PWD, PGPASSWORD),
never on its command line. It is a secret like the others: masked, revealed
on request, exported only sealed.
Backups go to backups/<connection>/<stack>/<service>/ in the data folder
(Settings → Update safety → Backup folder, e.g. a NAS mount), named
<UTC time>_<version>.sql.gz or .data.tar.gz, each with a .json
manifest (checksum, size, server version, databases, the update it was taken
for). The newest 5 of each kind are kept. The drawer lists them with a
download link, and the update's log names its backup.
Restoring a backup
Restore next to a backup in the drawer asks you to type the service's name, then (as an entry under Updates) loads a dump into the running database with its own client, or, for a copy of the data, stops the container, empties its data directory through a helper container from the same image, copies the backup in and starts it again.
By hand, for a dump, after putting back the old version if needed:
gunzip -c 20261104T030000Z_8.0.40.sql.gz | docker exec -i <container> sh -c 'mysql -uroot -p"$MYSQL_ROOT_PASSWORD"'
(mariadb instead of mysql, or psql -U postgres for PostgreSQL). A
dump made by an older version loads into a newer one; into the same version
is always safe. For a copy of the data, stop the container and replace the
contents of its data volume with the archive (it holds the directory itself,
e.g. mysql/): docker run --rm --volumes-from <container> -v $PWD:/backup <old image> sh -c 'rm -rf /var/lib/mysql/* && tar -xzf /backup/<file>.data.tar.gz -C /var/lib', then start it on the old image.
AI log review
Off by default (Settings → AI log review). When an update's logs show new errors but nothing fatal, a model can be asked whether the service works: advise shows its verdict with the decision, decide also acts on it when it is at least as sure as you set (80% by default): a confident failed rolls the update back, a confident healthy keeps it without asking. It never overrides a rule that failed an update, and is asked at most twice per update (after it comes up, and during the watch if something new turns up).
It is sent the image, the versions, the preset's note, the release notes, the old version's normal lines and the new lines, after taking out every value of the container's environment, anything shaped like a password, token, key or credential in a link, and email and IP addresses. Exactly what was sent is kept with the update (under Log). Without a verdict (the model declined, 30 s passed, the answer didn't follow the JSON schema it is held to), the rules decide alone.
Providers: Anthropic (Claude, with an API key; claude-opus-5-5 by
default, claude-haiku-5-5 costs less) or any OpenAI-compatible server,
such as a local Ollama (http://ollama:11434/v1) or LM Studio, so nothing
leaves your network.
Configuration
| Variable | Purpose |
|---|---|
PORTAINER_URL, PORTAINER_API_KEY |
first Portainer instance, managing all its environments (more in Settings) |
PORTAINER_INSECURE_SKIP_VERIFY |
true to accept that instance's self-signed certificate |
DOCKER_HOST |
first Docker host Belfry reaches directly, e.g. unix:///var/run/docker.sock or tcp://docker-proxy:2375 |
BELFRY_LISTEN |
listen address, default :8080 |
BELFRY_DATA_DIR |
SQLite location, default /data |
PUID, PGID |
user and group Belfry runs as in the container, default 1000 |
BELFRY_BASE_URL |
public URL of Belfry: required for OIDC redirects, and seeds the address notifications link to |
BELFRY_CHECK_CRON |
registry check schedule, default 0 */6 * * * |
BELFRY_WINDOW_CRON |
maintenance window, default 0 3 * * * (in TZ) |
DISCORD_WEBHOOK_URL |
Discord webhook |
NTFY_URL, NTFY_TOPIC, NTFY_TOKEN |
ntfy server, topic and optional access token |
DOCKERHUB_USERNAME, DOCKERHUB_TOKEN |
raises Docker Hub's anonymous rate limit for tag listing; Docker hosts also pull with it |
OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET |
enable single sign-on |
OIDC_REDIRECT_URL |
defaults to $BELFRY_BASE_URL/auth/oidc/callback |
OIDC_SCOPES |
default openid profile email |
OIDC_AUTO_CREATE_USERS |
default true; false only lets pre-linked users in |
OIDC_DISPLAY_NAME |
label on the login button, e.g. Authentik |
Update safety, backups and the AI review are set in Settings, not variables.
Authentik example
Create an OAuth2/OpenID provider with redirect URI
https://belfry.example.com/auth/oidc/callback, client type confidential,
and an application bound to it. Then:
BELFRY_BASE_URL=https://belfry.example.com
OIDC_ISSUER=https://auth.example.com/application/o/belfry/
OIDC_CLIENT_ID=<client id>
OIDC_CLIENT_SECRET=<client secret>
OIDC_DISPLAY_NAME=Authentik
Belfry uses the authorization-code flow with PKCE and reads identity from the provider's userinfo endpoint. The first local account still exists for break-glass access.
Limits (v1)
- Compose stacks only. Git-backed stacks and Swarm stacks are listed as unsupported; update the repository for those.
- One
image:line per service, written literally or as${VAR}/repo:${TAG}. Anything fancier is reported rather than guessed. - Pre-release tags (
rc,beta,nightly…) are ignored unless your filter matches them explicitly. - Portainer Community Edition is enough; nothing here needs Business Edition.
- Docker hosts: plain HTTP or the unix socket (TLS client certificates are on the roadmap), and pulls are anonymous except for Docker Hub with the account in Settings, so images from private registries can't be pulled yet.
- Watches only notify; they never update anything. Manifest plugins read JSON APIs and RSS/Atom feeds with GET requests. Anything else needs an HTTP plugin.
- Security advisories come from what projects publish on GitHub, matched by
version number against the running tag. A tag that isn't a version
(
:latestbefore you adopt a version) can't be matched. - Database backups run commands in the container (
docker exec), directly or through Portainer's Docker proxy (tested with Portainer CE 2.45.3 and Docker 29.9). - Logs are read through the Docker API, so a container with a logging driver
that can't be read back (
none,syslogwithout dual logging) only gets its container state checked, and an image whose preset requires a readiness line fails its check.
Building and developing
make build # go build → ./belfry (needs a C compiler for SQLite)
make check # gofmt, vet, unit tests, UI syntax
make e2e # full update/rollback flow against the mock Portainer and Docker host in hack/
hack/realdb.sh # MySQL 8.0 → 9.7 against a real Docker daemon (Docker-in-Docker)
BELFRY_LIVE_DOCKER=unix:///var/run/docker.sock BELFRY_LIVE_CONTAINER=<id> \
go test -tags live ./internal/docker # exec, archive and logs against a real Docker API or Portainer's proxy
make docker # docker build -t belfry .
make screenshots # regenerate docs/screenshots from the demo homelab in hack/demo
The UI is plain HTML/JS embedded in the binary; there is no frontend toolchain.
CLAUDE.md documents the architecture, invariants and conventions for anyone
(human or Claude Code) working on the code; docs/ROADMAP.md lists what's next.
CI (Forgejo Actions, .forgejo/workflows/ci.yml) runs the checks and the e2e
flow on every push and publishes git.pandanas.net/code-liberation-front/belfry
on pushes to main and on v* tags. The image is built with Kaniko, so the
runner needs no Docker daemon, and it is amd64 only. Publishing needs two
repository secrets: REGISTRY_USERNAME and REGISTRY_TOKEN (an access token
with write:package).
Layout
cmd/belfry entrypoint
internal/portainer Portainer API client
internal/docker Docker Engine API client, container recreation
internal/registry OCI tag listing + digests (bearer auth, no pulls)
internal/version tag parsing, ordering, filter generation
internal/policy latest / behind-N / pinned resolution, major-step cap
internal/compose find & rewrite one image line, env interpolation
internal/engine discovery, checks, scheduler, executor, rollback, watch window, backups
internal/health log signatures, baseline, fatal/error classes, readiness and version markers
internal/preset image presets: format and validation
internal/ai AI log review: redaction, Anthropic and OpenAI-compatible clients
internal/notify Discord, ntfy, in-app inbox
internal/plugin watch plugins: manifest format, templates, lookups and checks, catalogs
internal/backup config export format, passphrase encryption
internal/auth PBKDF2 passwords, sessions, OIDC (PKCE + userinfo)
internal/server REST API + static UI
internal/store SQLite
web/static the UI
plugins built-in plugins and the store's catalog (index.json); examples/
presets image presets (upgrade paths, log patterns, backups)
