Files
Andrew S Erwin 341cdce026
release gate / check (push) Canceled after 4m3s
release / smoke (push) Successful in 10m13s
release / publish (push) Failing after 12m48s
Registry mode: publish app/web/migrate images, drop source builds on hosts
The federated suite now installs Superbrain like every other house app:
pull images, run installapp, no source tree on the host.

Images (Docker Hub, federatedcomputer namespace, one shared tag per
release + :latest, linux/amd64 + linux/arm64):
  superbrain-app      Go API (scratch)
  superbrain-web      Next.js standalone
  superbrain-migrate  NEW self-contained db image: db/ baked in, entrypoint
                      db/bootstrap.sh waits for postgres, applies
                      schema.sql AS DB_USER on an empty database (object
                      ownership — migrations must be able to ALTER), then
                      always runs the checksummed ledger. Fresh install and
                      upgrade become the same command. The dev compose runs
                      the same bootstrap.sh (verified: non-empty DB skips
                      schema, applies pending migrations).

Release CI (.github/workflows/release.yml): semver tags without v prefix
(the suite's VERSION_RX); a smoke job bootstraps a throwaway PostgreSQL
with the migrate image (fresh schema + complete ledger + idempotent re-run)
and runs Go build/vet/unit BEFORE the publish job pushes — a broken db/
can never reach a tag the upgrade flow will pull. Requires
DOCKERHUB_USERNAME/DOCKERHUB_TOKEN secrets. Dockerfile stays legacy-
builder compatible (no BUILDPLATFORM cross-compile): dev hosts build
locally; CI builds each arch natively under qemu.

Federated integration:
- lib-superbrain.sh: compose pulls federatedcomputer/superbrain-*:
  ${IMAGE_VERSION} (bookstack quoting), no build: keys, no
  IMAGE_VERSION_HOLD; compose generation extracted into
  render_superbrain_compose (install + update share it); schema.sql
  pre-apply and host image builds removed; IMAGE_VERSION is the only
  VERSION= line in the generated .env (upgrade_app's sed matches every
  occurrence — the file says so in words that don't contain the pattern).
- service file: CONTAINER=federatedcomputer/superbrain-app (must equal the
  first image: repository — upgrade_app compares it), VERSION=1.0.0.
- services/superbrain/upgrade/pre hook (listmonk pattern): pre-upgrade
  pg_dump into .update-backups (5 retained) + pulls web/migrate at the
  target version (upgrade_app pulls only the app image).
- install.sh: registry messaging, installs the upgrade hook, clone is only
  for deploy files now.
- update.sh REWRITTEN for registry mode: the app dir no longer contains
  source, so it runs from a repo clone — sync lib/service/hook (parse-
  checked, backed up) -> re-render compose -> /federated/bin/upgrade
  superbrain -> same-version compose safety pass -> health probe.
- STRATEGY.md interim-mode section replaced with the registry-mode record.

README: federated section updated (pulls, not builds; house upgrade flow)
and a new 'Environment variable reference' section — every variable the
stack reads, required/optional, defaults, grouped (core, compose, access
policy, OIDC, SMTP, AI, federated-only, tests-only), so generated .env
files stay correct as features are added.
2026-10-29 10:21:10 -05:00

30 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Pre-upgrade hook for the house `upgrade` flow (installed at
# /federated/services/superbrain/upgrade/pre by install.sh / update.sh).
#
# Args (house convention): $1 = old version, $2 = new version.
#
# Two jobs:
# 1. Consistent pre-upgrade database backup (listmonk house pattern —
# the btrfs snapshot upgrade_app takes covers files, but a live dump
# is the restorable artifact). Last 5 kept under the app dir.
# 2. upgrade_app pulls only CONTAINER (the app image) before redeploying;
# superbrain is THREE images sharing one tag, so pull web + migrate at
# the target version too. Compose interpolates ${IMAGE_VERSION} from
# .env (still the old version at this point) — the shell environment
# wins over .env, so pin it explicitly.
set -euo pipefail
OLD="${1:-unknown}"
NEW="${2:?usage: pre <old-version> <new-version>}"
cd /federated/apps/superbrain
mkdir -p .update-backups && chmod 700 .update-backups
DUMP=".update-backups/pre-upgrade-$OLD-to-$NEW-$(date +%Y%m%d-%H%M%S).sql.gz"
echo "* Backing up the superbrain database to $DUMP"
docker exec postgresql /bin/bash -c "pg_dump superbrain -U postgres -c" | gzip > "$DUMP"
ls -1t .update-backups/pre-upgrade-*.sql.gz 2>/dev/null | tail -n +6 | xargs -r rm -f
echo "* Pulling superbrain images at $NEW"
IMAGE_VERSION="$NEW" docker compose pull app web migrate