Files
nanobot/docker-compose.yml
T
LuckVd ddd22a26f8 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
2026-10-19 13:02:26 +08:00

74 lines
1.9 KiB
YAML

x-common-config: &common-config
build:
context: .
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:
- ALL
# Entrypoint uses these to fix bind-mount ownership and drop to the nanobot user.
cap_add:
- CHOWN
- SETGID
- SETUID
# Prevent the non-root process from regaining capabilities through setuid
# binaries or file capabilities left inside the container image.
security_opt:
- no-new-privileges:true
services:
nanobot-gateway:
container_name: nanobot-gateway
<<: *common-config
command: ["gateway"]
restart: unless-stopped
ports:
- 127.0.0.1:18790:18790
- 8765:8765
deploy:
resources:
limits:
cpus: "1"
memory: 1G
reservations:
cpus: "0.25"
memory: 256M
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
ports:
- 127.0.0.1:8900:8900
deploy:
resources:
limits:
cpus: "1"
memory: 1G
reservations:
cpus: "0.25"
memory: 256M
nanobot-cli:
<<: *common-config
profiles:
- cli
command: ["status"]
stdin_open: true
tty: true