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

+11
View File
@@ -4,6 +4,12 @@ x-common-config: &common-config
dockerfile: Dockerfile
args:
NANOBOT_CHANNELS: ${NANOBOT_CHANNELS:-whatsapp}
environment:
# Bootstrap a working config.json on first boot (binds that work across
# the container boundary; secrets generated if not provided).
NANOBOT_DOCKER_BOOTSTRAP: "1"
NANOBOT_WEB_TOKEN: ${NANOBOT_WEB_TOKEN:-}
NANOBOT_API_KEY: ${NANOBOT_API_KEY:-}
volumes:
- ~/.nanobot:/home/nanobot/.nanobot
cap_drop:
@@ -39,6 +45,11 @@ services:
nanobot-api:
container_name: nanobot-api
<<: *common-config
# Optional: the OpenAI-compatible API needs a configured provider before it
# can serve, so it is not part of the default `docker compose up`. Start it
# with `docker compose --profile api up -d` once a provider is configured.
profiles:
- api
command:
["serve", "--host", "0.0.0.0", "-w", "/home/nanobot/.nanobot/api-workspace"]
restart: unless-stopped