Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(docker): preserve explicit config selectors during bootstrap
chengyongru103840171b47
diff --git a/docs/deployment.md b/docs/deployment.mdindex b2fb74f6d..54033534e 100644--- a/docs/deployment.md+++ b/docs/deployment.md@@ -95,7 +95,7 @@ docker compose logsOn first boot, Compose initializes `~/.nanobot/config.json` with container bind addresses and random WebUI/API credentials. Open `http://HOST:8765`, enter the WebUI password printed in the first-boot logs, then configure your provider and model in **Settings → Models**. Send a message to verify the setup. No provider is required just to open the WebUI.-Export `NANOBOT_WEB_TOKEN` or `NANOBOT_API_KEY` before the first startup to supply your own credentials. Compose forwards these variables into the containers. Existing configuration is left untouched, including credentials and bind addresses; changing these variables later does not rotate persisted credentials. If you reuse an existing configuration, check the [Docker bind and authentication settings](#docker) above.+Export `NANOBOT_WEB_TOKEN` or `NANOBOT_API_KEY` before the first startup to supply your own credentials. Compose forwards these variables into the containers. Existing configuration is left untouched, including credentials and bind addresses; changing these variables later does not rotate persisted credentials. An explicit `--config` or `-c` selects a user-managed configuration and skips default-instance initialization. If you reuse an existing configuration, check the [Docker bind and authentication settings](#docker) above.The configuration and workspace persist in the `~/.nanobot` bind mount. Keep `agents.defaults.workspace` as a container path, normally `~/.nanobot/workspace`, rather than a host home-directory path. Other config `${VAR}` references require explicit `environment` entries in the CLI and gateway services; Compose does not forward arbitrary host variables.diff --git a/entrypoint.sh b/entrypoint.shindex d69e047ad..1812e19e7 100755--- a/entrypoint.sh+++ b/entrypoint.sh@@ -43,9 +43,18 @@ if [ "$RENDER" = "true" ]; thenfiset -- "$@" --config "$config"elif [ "$NANOBOT_DOCKER_BOOTSTRAP" = "1" ] && { [ "$1" = "gateway" ] || [ "$1" = "serve" ]; }; then- config="$dir/config.json"- python -m nanobot.cli.docker_bootstrap "$config" || exit 1- set -- "$@" --config "$config"+ # Explicit config selectors belong to the CLI; bootstrap only the default instance.+ initialize_default=1+ for argument in "$@"; do+ case "$argument" in+ --config|--config=*|-c*) initialize_default=0; break ;;+ esac+ done+ if [ "$initialize_default" = "1" ]; then+ config="$dir/config.json"+ python -m nanobot.cli.docker_bootstrap "$config" || exit 1+ set -- "$@" --config "$config"+ fifiexec nanobot "$@"diff --git a/scripts/docker_compose_smoke.py b/scripts/docker_compose_smoke.pyindex a6e3867e9..5d7e6c8bf 100644--- a/scripts/docker_compose_smoke.py+++ b/scripts/docker_compose_smoke.py@@ -169,6 +169,55 @@ def main() -> None:"-R", f"{os.getuid()}:{os.getgid()}", "/data",], check=True)+ commands = {name: list(service["command"]) for name, service in config["services"].items()}+ selected_path = "/home/nanobot/.nanobot/selected.json"+ selectors = (+ ("long", ["--config", selected_path]),+ ("long-equals", [f"--config={selected_path}"]),+ ("short", ["-c", selected_path]),+ ("short-attached", [f"-c{selected_path}"]),+ )+ for service_name in ("nanobot-gateway", "nanobot-api"):+ for label, selector in selectors:+ data = root / f"{service_name}-{label}"+ data.mkdir()+ selected = data / "selected.json"+ selected.write_text(json.dumps(saved), encoding="utf-8")+ previous = selected.read_bytes()+ for service in config["services"].values():+ service["volumes"] = [{+ "type": "bind", "source": str(data),+ "target": "/home/nanobot/.nanobot",+ }]+ config["services"][service_name]["command"] = [*commands[service_name], *selector]+ compose_path.write_text(json.dumps(config), encoding="utf-8")+ try:+ run("up", "-d", "--no-deps", service_name)+ gateway = service_name == "nanobot-gateway"+ health = endpoint(service_name, 18790 if gateway else 8900)+ wait_for(health + "/health")+ if gateway:+ webui = endpoint(service_name, 8765)+ assert request(webui + "/webui/bootstrap", password)[0] == 200+ else:+ assert request(health + "/v1/models", api_key)[0] == 200+ assert request(health + "/v1/models", "changed-env")[0] == 401+ assert selected.read_bytes() == previous+ assert not (data / "config.json").exists()+ assert "[entrypoint] initialized" not in run("logs", "--no-color")+ print(f"PASS {service_name} {label}: explicit config preserved without default initialization")+ except Exception:+ print(run("logs", "--no-color", "--tail", "80"), flush=True)+ raise+ finally:+ subprocess.run([*compose, "down", "--volumes"], check=True)+ if os.name != "nt":+ subprocess.run([+ "docker", "run", "--rm", "--entrypoint", "chown",+ "-v", f"{data}:/data", args.image,+ "-R", f"{os.getuid()}:{os.getgid()}", "/data",+ ], check=True)+readonly = root / "readonly"readonly.mkdir()result = subprocess.run([