Ship install/update scripts in the migrate image; no repo clone on hosts
This commit is contained in:
@@ -352,13 +352,13 @@ Authelia + shared postgres + pdns + superpanel), Superbrain is a
|
||||
first-class suite app. On the **core host**, as root:
|
||||
|
||||
```bash
|
||||
git clone https://gitea.federated.computer/Federated_Computer/brain.git /tmp/superbrain-repo
|
||||
sudo bash /tmp/superbrain-repo/deploy/federated/install.sh
|
||||
sudo bash -c "$(docker run --rm --pull always federatedcomputer/superbrain-migrate cat /deploy/install.sh)"
|
||||
```
|
||||
|
||||
(Use whichever repository location you were given access to; the installer
|
||||
re-clones it onto the host by default — override with `SUPERBRAIN_REPO`,
|
||||
`SUPERBRAIN_REF`, or stage a local tree with `SUPERBRAIN_SRC`.)
|
||||
No clone and nothing to copy: the installer and the suite integration files
|
||||
ship inside the migrate image at `/deploy`. Pin a release with
|
||||
`SUPERBRAIN_VERSION=1.2.3` (default `latest`), or use a local checkout's
|
||||
files instead with `SUPERBRAIN_SRC=/path/to/repo`.
|
||||
|
||||
The installer:
|
||||
|
||||
@@ -393,19 +393,18 @@ history: [deploy/federated/STRATEGY.md](deploy/federated/STRATEGY.md).
|
||||
in `/federated/services/superbrain/service` to the new release tag and run
|
||||
`/federated/bin/upgrade superbrain` (the pre-hook backs up the database
|
||||
and pulls all three images). Or one command, which also syncs the suite
|
||||
files from the repo:
|
||||
files from the release's migrate image (version defaults to `latest`):
|
||||
|
||||
```bash
|
||||
git clone https://gitea.federated.computer/Federated_Computer/brain.git /tmp/superbrain-repo
|
||||
sudo bash /tmp/superbrain-repo/deploy/federated/update.sh [git-ref]
|
||||
sudo bash -c "$(docker run --rm --pull always federatedcomputer/superbrain-migrate cat /deploy/update.sh)" update.sh [version]
|
||||
```
|
||||
|
||||
Releases are semver tags without a `v` prefix (`1.0.0`); CI builds and
|
||||
pushes all three images under the same tag (plus `:latest`) for
|
||||
linux/amd64 and linux/arm64. The migrate image is self-contained: it
|
||||
detects an empty database, applies `schema.sql` as the superbrain user,
|
||||
then runs the checksummed migration ledger — the host never needs the
|
||||
source tree.
|
||||
then runs the checksummed migration ledger, and it carries
|
||||
`deploy/federated/` at `/deploy` — the host never needs the source tree.
|
||||
|
||||
## Publishing release images (Docker Hub)
|
||||
|
||||
@@ -466,7 +465,7 @@ docker run --privileged --rm tonistiigi/binfmt --install arm64
|
||||
docker login -u <dockerhub-user> # token prompt
|
||||
|
||||
# Smoke the migrate image BEFORE publishing (mirrors the CI gate):
|
||||
docker build -t sb-migrate:smoke db/
|
||||
docker buildx build --load --build-context deploy=deploy/federated -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
|
||||
@@ -480,19 +479,22 @@ docker buildx build --platform linux/amd64,linux/arm64 --push \
|
||||
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 \
|
||||
--build-context deploy=deploy/federated \
|
||||
-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
|
||||
migrate image is `postgres:16.15-alpine` + `db/` + `deploy/federated/`
|
||||
(supplied as the named `deploy` build context), 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
|
||||
and release it — hosts sync the service file via `update.sh` from the
|
||||
migrate image), 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
|
||||
|
||||
Reference in New Issue
Block a user