diff --git a/README.md b/README.md index 2f47b7f..c28a2e0 100644 --- a/README.md +++ b/README.md @@ -407,6 +407,97 @@ detects an empty database, applies `schema.sql` as the superbrain user, then runs the checksummed migration ledger — the host never needs the source tree. +## Publishing release images (Docker Hub) + +Releases are three multi-arch images sharing **one semver tag without a `v` +prefix** (the suite's `VERSION_RX` is `^[0-9][0-9\.]*$`), plus `:latest`: + +``` +federatedcomputer/superbrain-app: Go API (context ., Dockerfile) +federatedcomputer/superbrain-web: Next.js UI (context web, web/Dockerfile) +federatedcomputer/superbrain-migrate: DB bootstrap (context db, db/Dockerfile) +``` + +Platforms: `linux/amd64,linux/arm64`. Source of truth: this Gitea repo +(`https://gitea.federated.computer/Federated_Computer/brain.git`) at the +matching tag. The repositories auto-create on first push under the +`federatedcomputer` namespace; keep them **public** so cores can pull +without registry credentials. Never move an existing tag — cut a new +version instead. + +### Option A — CI (preferred): push a tag + +`.github/workflows/release.yml` runs on Gitea Actions for tags matching +`[0-9]+.[0-9]+.[0-9]+`. A smoke job first builds the migrate image and +bootstraps a throwaway PostgreSQL with it (fresh schema, complete ledger, +idempotent re-run) and runs Go build/vet/unit tests; only then does the +publish job build and push all three images. Prerequisites (one-time, +instance admin): + +1. An **act_runner** registered against `https://gitea.federated.computer` + with access to a docker socket. +2. Repo/org **Actions secrets** `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` + (an access token with write permission on the `federatedcomputer` + namespace). + +Then releasing is: + +```bash +git checkout main && git pull +git tag -a 1.2.3 -m "release 1.2.3" +git push origin 1.2.3 +``` + +Watch the run under the repo's Actions tab; verify with +`docker manifest inspect federatedcomputer/superbrain-app:1.2.3`. + +### Option B — manual build & push (no runner required) + +From any Linux machine with Docker, buildx and login rights: + +```bash +git clone https://gitea.federated.computer/Federated_Computer/brain.git +cd brain && git checkout 1.2.3 # always build from the tag + +# One-time per machine: buildx builder + cross-arch emulation +docker buildx create --use --name multiarch +docker run --privileged --rm tonistiigi/binfmt --install arm64 + +docker login -u # token prompt + +# Smoke the migrate image BEFORE publishing (mirrors the CI gate): +docker build -t sb-migrate:smoke db/ +docker run -d --name sb-smoke-pg -e POSTGRES_USER=superbrain \ + -e POSTGRES_PASSWORD=x -e POSTGRES_DB=superbrain postgres:16.15-alpine +docker run --rm --link sb-smoke-pg -e DB_HOST=sb-smoke-pg -e PGPASSWORD=x sb-migrate:smoke +docker run --rm --link sb-smoke-pg -e DB_HOST=sb-smoke-pg -e PGPASSWORD=x sb-migrate:smoke # re-run: "up to date" +docker rm -f sb-smoke-pg + +# Build + push all three (each command pushes and latest): +V=1.2.3 +docker buildx build --platform linux/amd64,linux/arm64 --push \ + -t federatedcomputer/superbrain-app:$V -t federatedcomputer/superbrain-app:latest . +docker buildx build --platform linux/amd64,linux/arm64 --push \ + -t federatedcomputer/superbrain-web:$V -t federatedcomputer/superbrain-web:latest web +docker buildx build --platform linux/amd64,linux/arm64 --push \ + -t federatedcomputer/superbrain-migrate:$V -t federatedcomputer/superbrain-migrate:latest db +``` + +Notes: the arm64 web build runs under qemu and is the slow step (tens of +minutes on modest hardware); the app image is a static Go binary and the +migrate image is `postgres:16.15-alpine` + `db/`, both quick. Go builds +must stay legacy-builder compatible (no `$BUILDPLATFORM` tricks) so local +`docker compose build` keeps working on hosts without BuildKit defaults. + +### After publishing + +Bump `VERSION=` in `deploy/federated/service` to the new tag (commit it — +hosts sync the service file via `deploy/federated/update.sh`), then on each +core: `/federated/bin/upgrade superbrain` (or update.sh, which syncs the +service file first). The pre-upgrade hook takes a pg_dump and pulls all +three images; `upgrade_app` snapshots, redeploys and rewrites +`IMAGE_VERSION` in the app `.env`. + ## Environment variable reference Everything the stack reads, so a generated `.env` (or hosting environment)