Bootstrap a working Docker Compose config on first boot so the WebUI works out of the box

A fresh 'docker compose up' started with no config (the entrypoint only
bootstrapped for Render), so every published port was unreachable: the
gateway and WebSocket channel defaulted to a container-local 127.0.0.1
bind, and nanobot-api exited into a restart loop because serve refuses a
non-loopback host without an api_key.

Bootstrap config.json for container runs (NANOBOT_DOCKER_BOOTSTRAP, set
by docker-compose.yml) from a committed docker-config.json with binds
that survive the container boundary, baking the WebUI token and API key
at first boot (env value if provided, generated otherwise, printed to
the log). Move nanobot-api under the 'api' profile since it cannot
serve before a provider is configured. Install curl in the image and
document the new first-boot flow.

Fixes #6165
This commit is contained in:
LuckVd authored and chengyongru committed 2026-10-19 13:02:26 +08:00
1 parent 53e0edf709
commit ddd22a26f8
6 files changed
+153 -14

No files matched your search

+15
View File
@@ -131,6 +131,21 @@ NANOBOT_CHANNELS=telegram,slack docker compose build
The image keeps nanobot in a virtual environment owned by its built-in non-root runtime user (UID 1000). If an enabled channel was not preinstalled, gateway startup can therefore install its manifest-declared dependencies. Rebuilding with `NANOBOT_CHANNELS` keeps that installation reproducible instead of relying on the container's writable layer. If you override the container with a different `--user`, bake every enabled channel into the image because that UID is not guaranteed write access to the virtual environment.
The first `docker compose up` bootstraps `~/.nanobot/config.json` with container-appropriate binds and generated secrets: the WebUI password (`NANOBOT_WEB_TOKEN`) and the OpenAI-compatible API key (`NANOBOT_API_KEY`). Export either variable before `up` to pin your own; otherwise the entrypoint generates one and prints it to the container log. An existing `config.json` is left untouched. Add provider keys afterwards in the WebUI settings or with `onboard`:
```bash
docker compose up -d nanobot-gateway # first boot writes ~/.nanobot/config.json
docker compose logs nanobot-gateway # shows the generated WebUI password and API key
```
The `nanobot-api` service (OpenAI-compatible endpoint on `127.0.0.1:8900`) needs a configured provider before it can serve, so it is opt-in via the `api` profile:
```bash
docker compose --profile api up -d # also start the API once a provider is configured
```
For a fully pre-configured setup, keep using first-time onboarding:
```bash
docker compose run --rm nanobot-cli status
docker compose run --rm nanobot-cli agent -m "Hello!"