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.
This commit is contained in:
Jannic Debus 2026-11-19 19:47:51 +01:00
parent 0d7f51d26d
commit 64189e6140
3 changed files with 160 additions and 5 deletions

68
.env.template Normal file
View file

@ -0,0 +1,68 @@
# Version Tags
IMAGE_TAG=5.0.3
AIDO_WEB_IMAGE=git.livtec.cloud/aido/aido-web:5.0.3-1
AIDO_WEB_PULL_POLICY=always
## Settings
SESSION_EXPIRE_TIME_SECONDS=604800 # 7 days
AUTH_COOKIE_EXPIRE_TIME_SECONDS=604800 # 7 days
AUTH_TYPE=oidc
OIDC_PKCE_ENABLED=true
TRACK_EXTERNAL_IDP_EXPIRY=true
OIDC_SCOPE_OVERRIDE=openid,email,profile,offline_access
ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=false
POSTGRES_USER=onyx-admin
POSTGRES_API_SERVER_POOL_SIZE=30 # Tune for your load
POSTGRES_API_SERVER_POOL_OVERFLOW=10
POSTGRES_TCP_KEEPALIVES=1 # Enable keepalives
POSTGRES_TCP_KEEPALIVES_IDLE=60 # 60 seconds idle
POSTGRES_TCP_KEEPALIVES_INTERVAL=10 # 10 seconds between probes
POSTGRES_TCP_KEEPALIVES_COUNT=5 # 5 probes before disconnect
COMPOSE_PROFILES=s3-filestore
FILE_STORE_BACKEND=s3
NGINX_PROXY_CONNECT_TIMEOUT=600 # 10 minutes (complex AI queries)
NGINX_PROXY_SEND_TIMEOUT=600
NGINX_PROXY_READ_TIMEOUT=600
CELERY_BROKER_POOL_LIMIT=0
CELERY_WORKER_DOCFETCHING_CONCURRENCY=2
CELERY_WORKER_DOCPROCESSING_CONCURRENCY=1
CELERY_WORKER_LIGHT_CONCURRENCY=4
CELERY_WORKER_LIGHT_PREFETCH_MULTIPLIER=1
USE_IAM_AUTH=false
LOG_LEVEL=info
LOG_ONYX_MODEL_INTERACTIONS=False
DISABLE_TELEMETRY=true
SHOW_EXTRA_CONNECTORS=true
GEN_AI_MAX_TOKENS=250000
LLM_SOCKET_READ_TIMEOUT=600
DISABLE_LITELLM_STREAMING=false
GENERATIVE_MODEL_ACCESS_CHECK_FREQ=300 # 5 minutes
EMBEDDING_BATCH_SIZE=100
HIDE_QUERY_HISTORY_FROM_ADMIN_PANEL=true
INTERNAL_URL=http://api_server:8080
ENABLE_CONTEXTUAL_RAG=true
## Secrets
USER_AUTH_SECRET=$(openssl rand -hex 16)
ENCRYPTION_KEY_SECRET=$(openssl rand -hex 32)
METRICS_AUTH_TOKEN=$(openssl rand -hex 32)
OPENSEARCH_ADMIN_PASSWORD=$(openssl rand -hex 16)
POSTGRES_PASSWORD=$(openssl rand -hex 16)
# S3 Credentials
S3_ENDPOINT_URL=
S3_REGION=us-east-1
S3_AWS_ACCESS_KEY_ID=
S3_AWS_SECRET_ACCESS_KEY=
S3_FILE_STORE_BUCKET_NAME=
# Duo SSO
OAUTH_CLIENT_ID=
OAUTH_CLIENT_SECRET=
OPENID_CONFIG_URL=
# FQDN
CORS_ALLOWED_ORIGIN=
WEB_DOMAIN=
FQDN=

83
PREBUILT-IMAGE.md Normal file
View file

@ -0,0 +1,83 @@
# 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.

View file

@ -152,11 +152,15 @@ services:
# - ${CA_CERT_PATH:-./custom-ca.crt}:/etc/ssl/certs/custom-ca.crt:ro # - ${CA_CERT_PATH:-./custom-ca.crt}:/etc/ssl/certs/custom-ca.crt:ro
web_server: web_server:
# Branded AIDO web image, built locally from ./web after `make apply`. # Branded AIDO web image. Two modes (see docs/PREBUILT-IMAGE.md):
# This is the ONLY locally-built image; every other service below uses the # - Local build (default): built from ./web after `make apply`. This is the
# official Onyx images unchanged. pull_policy: never => never overwrite it. # ONLY locally-built image; every other service uses official Onyx images.
image: livtec/aido-web:local # - Prebuilt image: set AIDO_WEB_IMAGE to a registry ref (e.g.
pull_policy: never # registry.example.com/aido-web:5.0.3-1) and AIDO_WEB_PULL_POLICY=always,
# then `docker compose pull web_server` on each instance — no local build,
# no 16 GB build host needed. Defaults below keep the local-build behaviour.
image: ${AIDO_WEB_IMAGE:-livtec/aido-web:local}
pull_policy: ${AIDO_WEB_PULL_POLICY:-never}
build: build:
context: ./web context: ./web
dockerfile: Dockerfile dockerfile: Dockerfile