aido-onyx/PREBUILT-IMAGE.md
livdebus 64189e6140 Support a prebuilt web image (build once, pull on each instance)
Parameterize the web_server image + pull policy so an instance can pull a
centrally-built image from a private registry instead of running the
~16 GB `make build` locally:

  image:       ${AIDO_WEB_IMAGE:-livtec/aido-web:local}
  pull_policy: ${AIDO_WEB_PULL_POLICY:-never}

Defaults keep the current local-build behaviour, so build hosts and local
dev are unaffected. Add docs/PREBUILT-IMAGE.md with the build-once /
push-to-private-registry / pull-everywhere workflow.
2026-11-19 19:47:51 +01:00

83 lines
No EOL
3.7 KiB
Markdown

# Prebuilt AIDO web image (build once, pull everywhere)
The white-label is the **only** thing we build — a single image, `livtec/aido-web:local`,
produced from `./web` after the branding overlay. Every other service (api_server,
background, model servers, postgres, opensearch, nginx, redis, …) already runs an
**official Onyx image, unchanged**.
So you can build that one image **once** on a build host, push it to your **private**
registry, and have every AIDO instance **pull** it — no per-instance `make build`, and
no 16 GB of RAM on the app instances (the 16 GB is only for the Next.js build itself,
which now runs on the build host only).
This needs no change on your side beyond the two environment variables below; the
`docker-compose.yml` already supports both modes (local build is still the default).
---
## 1. One-time: build and push (on a build host with ≥16 GB RAM)
```bash
git clone <aido-onyx repo> && cd aido-onyx
make setup # fetch the pinned Onyx web source into ./web
make apply # apply the AIDO white-label overlay into ./web
make build # build livtec/aido-web:local (needs ~16 GB, ~5-10 min)
# pick your private registry + a version tag (NOT :latest, so instances pin a build)
REG=registry.livtec.cloud/aido # e.g. your Git instance's container registry
VER=5.0.3-1 # onyx version + build number
docker tag livtec/aido-web:local $REG/aido-web:$VER
docker login registry.livtec.cloud
docker push $REG/aido-web:$VER
```
Your private Git instance almost certainly has a built-in **container registry**
(GitLab, Gitea and Forgejo all do) — use that, with auth. Do **not** use Docker Hub.
## 2. On each instance (no build, small RAM)
Instances need the repo (for `docker-compose.yml` + the nginx config under
`data/nginx`) and the prebuilt image — but never run `make build`.
```bash
git clone <aido-onyx repo> && cd aido-onyx
make setup # clones the web source + nginx config (cheap, no build, low RAM)
# point the stack at the prebuilt image (put these two lines in .env)
echo 'AIDO_WEB_IMAGE=registry.livtec.cloud/aido/aido-web:5.0.3-1' >> .env
echo 'AIDO_WEB_PULL_POLICY=always' >> .env
docker login registry.livtec.cloud
docker compose pull web_server # pulls the prebuilt image
docker compose up -d # starts the stack, no build
```
That's it — the instance runs the central build with zero local compilation.
## 3. Updating (new Onyx version or a branding change)
**Build host:** `git pull`, then `make setup && make apply && make build`, bump `VER`,
re-tag and `docker push`.
**Each instance:** bump `AIDO_WEB_IMAGE` to the new `VER` in `.env`, then
```bash
docker compose pull web_server
docker compose up -d --force-recreate web_server
```
## Notes
- **Keep it private.** Push only to your private registry, with authentication. The
image embeds your branding but no secrets; still, never publish it.
- **Version tags, not `:latest`.** Pinning a `VER` lets every instance run a known,
identical build and lets you roll back instantly (just point `AIDO_WEB_IMAGE` back).
- **Build host sizing.** Only the build host needs ~16 GB (for `next build`). App
instances can be sized for AIDO's actual runtime needs.
- **`data/nginx`.** Instances still need the nginx config that `make setup` copies; the
`./web` source is only used on the build host. `make setup` itself is lightweight
(a clone), so running it on an instance is fine — it's `make build` you're avoiding.
- **Defaults unchanged.** With `AIDO_WEB_IMAGE` unset, `docker-compose.yml` behaves
exactly as before (local build, `pull_policy: never`), so existing build hosts and
local development are unaffected.