Drops the multi-step paste-by-paste setup down to one command. Detects
every running ollama/ollama container on the host, classifies them
(embedded vs extras based on which Docker network they share with the
gateway), checks each one's auth config, rewrites OLLAMA_BACKENDS in
.env atomically, recreates the gateway, and probes everything.
What it does, in order:
1. preflight: docker on PATH, .env present, gateway container running
2. `docker ps --filter ancestor=ollama/ollama` → every running Ollama
3. for each one:
- find the network it shares with the gateway; attach to `proxy`
if it's on no shared network
- read OLLAMA_AUTH and OLLAMA_AUTH_TOKEN from `docker inspect`
- FAIL LOUD if auth=true with empty token (with the exact fix)
- classify: on a `*internal*` net = the gateway's embedded backend;
otherwise an extra
4. build the OLLAMA_BACKENDS JSON: embedded first (so it gets routing
priority), then extras in discovery order, with per-backend tokens
where present
5. write .env atomically (host-side temp + rename — no in-container
perm issues to worry about)
6. `docker compose up -d gateway` to pick up the new env
7. wait for /healthz, then run probe-ollama and list-backends so the
operator sees the end state immediately
Token is redacted before echoing the resulting OLLAMA_BACKENDS line, so
the script can run safely with terminal logging on.
Idempotent: re-running produces the same OLLAMA_BACKENDS line. No
half-states possible — every error path exits before .env is touched.
7.1 KiB
Executable File
7.1 KiB
Executable File