From 34d9122b45a42ab0ad0c234711dd406e211fcb26 Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 5 Mar 2026 09:15:46 -0600 Subject: [PATCH] Add one-command OpenClaw Docker UI smoke script --- doc/DEVELOPING.md | 10 ++ docs/guides/openclaw-docker-setup.md | 26 +++++ package.json | 3 +- scripts/smoke/openclaw-docker-ui.sh | 164 +++++++++++++++++++++++++++ 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100755 scripts/smoke/openclaw-docker-ui.sh diff --git a/doc/DEVELOPING.md b/doc/DEVELOPING.md index debc88f3..5eec30a7 100644 --- a/doc/DEVELOPING.md +++ b/doc/DEVELOPING.md @@ -274,3 +274,13 @@ Optional auth flags (for authenticated mode): - `PAPERCLIP_AUTH_HEADER` (for example `Bearer ...`) - `PAPERCLIP_COOKIE` (session cookie header value) + +## OpenClaw Docker UI One-Command Script + +To boot OpenClaw in Docker and print a host-browser dashboard URL in one command: + +```sh +pnpm smoke:openclaw-docker-ui +``` + +This script lives at `scripts/smoke/openclaw-docker-ui.sh` and automates clone/build/config/start for Compose-based local OpenClaw UI testing. diff --git a/docs/guides/openclaw-docker-setup.md b/docs/guides/openclaw-docker-setup.md index 5812be1b..4d90991d 100644 --- a/docs/guides/openclaw-docker-setup.md +++ b/docs/guides/openclaw-docker-setup.md @@ -25,6 +25,32 @@ Permissions note: - The harness performs board-governed actions (invite creation, join approval, wakeup of the new agent). - In authenticated mode, provide board/operator auth or the run exits early with an explicit permissions error. +## One-Command OpenClaw Gateway UI (Manual Docker Flow) + +To spin up OpenClaw in Docker and print a host-browser dashboard URL in one command: + +```bash +pnpm smoke:openclaw-docker-ui +``` + +What this command does: + +- clones/updates `openclaw/openclaw` in `/tmp/openclaw-docker` +- builds `openclaw:local` (unless `OPENCLAW_BUILD=0`) +- writes `~/.openclaw/openclaw.json` and Docker `.env` +- starts `openclaw-gateway` via Compose (with required `/tmp` tmpfs override) +- waits for health and prints: + - `http://127.0.0.1:18789/#token=...` + +Environment knobs: + +- `OPENAI_API_KEY` (required; loaded from env or `~/.secrets`) +- `OPENCLAW_DOCKER_DIR` (default `/tmp/openclaw-docker`) +- `OPENCLAW_GATEWAY_PORT` (default `18789`) +- `OPENCLAW_GATEWAY_TOKEN` (default random) +- `OPENCLAW_BUILD=0` to skip rebuild +- `OPENCLAW_OPEN_BROWSER=1` to auto-open the URL on macOS + ### Authenticated mode If your Paperclip deployment is `authenticated`, provide auth context: diff --git a/package.json b/package.json index f4c1ab98..b0ac83d5 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "version-packages": "changeset version", "check:tokens": "node scripts/check-forbidden-tokens.mjs", "docs:dev": "cd docs && npx mintlify dev", - "smoke:openclaw-join": "./scripts/smoke/openclaw-join.sh" + "smoke:openclaw-join": "./scripts/smoke/openclaw-join.sh", + "smoke:openclaw-docker-ui": "./scripts/smoke/openclaw-docker-ui.sh" }, "devDependencies": { "@changesets/cli": "^2.30.0", diff --git a/scripts/smoke/openclaw-docker-ui.sh b/scripts/smoke/openclaw-docker-ui.sh new file mode 100755 index 00000000..1845f176 --- /dev/null +++ b/scripts/smoke/openclaw-docker-ui.sh @@ -0,0 +1,164 @@ +#!/usr/bin/env bash +set -euo pipefail + +log() { + echo "[openclaw-docker-ui] $*" +} + +fail() { + echo "[openclaw-docker-ui] ERROR: $*" >&2 + exit 1 +} + +require_cmd() { + local cmd="$1" + command -v "$cmd" >/dev/null 2>&1 || fail "missing required command: $cmd" +} + +require_cmd docker +require_cmd git +require_cmd curl +require_cmd openssl +require_cmd grep + +OPENCLAW_REPO_URL="${OPENCLAW_REPO_URL:-https://github.com/openclaw/openclaw.git}" +OPENCLAW_DOCKER_DIR="${OPENCLAW_DOCKER_DIR:-/tmp/openclaw-docker}" +OPENCLAW_IMAGE="${OPENCLAW_IMAGE:-openclaw:local}" +OPENCLAW_CONFIG_DIR="${OPENCLAW_CONFIG_DIR:-$HOME/.openclaw}" +OPENCLAW_WORKSPACE_DIR="${OPENCLAW_WORKSPACE_DIR:-$OPENCLAW_CONFIG_DIR/workspace}" +OPENCLAW_GATEWAY_PORT="${OPENCLAW_GATEWAY_PORT:-18789}" +OPENCLAW_BRIDGE_PORT="${OPENCLAW_BRIDGE_PORT:-18790}" +OPENCLAW_GATEWAY_BIND="${OPENCLAW_GATEWAY_BIND:-lan}" +OPENCLAW_GATEWAY_TOKEN="${OPENCLAW_GATEWAY_TOKEN:-$(openssl rand -hex 32)}" +OPENCLAW_BUILD="${OPENCLAW_BUILD:-1}" +OPENCLAW_WAIT_SECONDS="${OPENCLAW_WAIT_SECONDS:-45}" +OPENCLAW_OPEN_BROWSER="${OPENCLAW_OPEN_BROWSER:-0}" +OPENCLAW_SECRETS_FILE="${OPENCLAW_SECRETS_FILE:-$HOME/.secrets}" + +if [[ -z "${OPENAI_API_KEY:-}" && -f "$OPENCLAW_SECRETS_FILE" ]]; then + set +u + # shellcheck source=/dev/null + source "$OPENCLAW_SECRETS_FILE" + set -u +fi + +[[ -n "${OPENAI_API_KEY:-}" ]] || fail "OPENAI_API_KEY is required (set env var or include it in $OPENCLAW_SECRETS_FILE)" + +log "preparing OpenClaw repo at $OPENCLAW_DOCKER_DIR" +if [[ -d "$OPENCLAW_DOCKER_DIR/.git" ]]; then + git -C "$OPENCLAW_DOCKER_DIR" fetch --quiet origin || true + git -C "$OPENCLAW_DOCKER_DIR" checkout --quiet main || true + git -C "$OPENCLAW_DOCKER_DIR" pull --ff-only --quiet origin main || true +else + rm -rf "$OPENCLAW_DOCKER_DIR" + git clone "$OPENCLAW_REPO_URL" "$OPENCLAW_DOCKER_DIR" +fi + +if [[ "$OPENCLAW_BUILD" == "1" ]]; then + log "building Docker image $OPENCLAW_IMAGE" + docker build -t "$OPENCLAW_IMAGE" -f "$OPENCLAW_DOCKER_DIR/Dockerfile" "$OPENCLAW_DOCKER_DIR" +fi + +log "writing OpenClaw config under $OPENCLAW_CONFIG_DIR" +mkdir -p "$OPENCLAW_WORKSPACE_DIR" "$OPENCLAW_CONFIG_DIR/identity" "$OPENCLAW_CONFIG_DIR/credentials" +chmod 700 "$OPENCLAW_CONFIG_DIR" "$OPENCLAW_CONFIG_DIR/credentials" + +cat > "$OPENCLAW_CONFIG_DIR/openclaw.json" < "$OPENCLAW_DOCKER_DIR/.env" < "$COMPOSE_OVERRIDE" </dev/null 2>&1; then + log "opening dashboard in browser" + open "$dashboard_url" +fi