Skip to content

fix: fresh deploy compat fixes (gosu grep, wrangler 4.71 placeholders, docs)#4

Open
theredspoon wants to merge 4 commits intosimple10:mainfrom
theredspoon:fix/deploy-compat-fixes
Open

fix: fresh deploy compat fixes (gosu grep, wrangler 4.71 placeholders, docs)#4
theredspoon wants to merge 4 commits intosimple10:mainfrom
theredspoon:fix/deploy-compat-fixes

Conversation

@theredspoon
Copy link

@theredspoon theredspoon commented Mar 7, 2026

Summary

Issues found during a fresh deployment on Ubuntu 25.04 with Wrangler 4.71.

  • fix(build): build-openclaw.sh used grep -q "docker.io" to detect whether the Dockerfile had already been patched. Upstream Dockerfile v2026.3.2 introduced a LABEL org.opencontainers.image.base.name="docker.io/library/node:22-bookworm" line, causing a false positive — the gosu+Docker patch was silently skipped, and containers crashed in the entrypoint with gosu: command not found. Fixed by grepping for "gosu" instead, which is only present after the patch is applied.

  • fix(workers): Wrangler 4.71 validates the entire wrangler.jsonc config before executing any subcommand, including kv namespace create and d1 create. The example files had "id": "" (KV) and "database_id": "<run: npx wrangler d1 create>" (D1) as placeholders — both fail schema validation before the create command can run. Replaced with valid-format dummy values (00000000000000000000000000000000 / 00000000-0000-0000-0000-000000000000) that pass validation.

  • fix(compose): With bridge networking, localhost:PORT inside the cloudflared container resolves to the cloudflared container itself — not the host where openclaw gateway ports are published (127.0.0.1:PORT). This causes Cloudflare 520 errors on every first deploy. Switch cloudflared to network_mode: host so localhost resolves correctly.

  • docs(workers): Several undocumented prerequisites caused confusing failures:

    1. workers.dev subdomain must be registered before first deploy (wrangler exits without a clear error if not)
    2. CLOUDFLARE_API_TOKEN requires Workers Scripts:Edit, Workers KV Storage:Edit, and D1:Edit permissions — the previous prerequisite list was incomplete
    3. Multi-account tokens need CLOUDFLARE_ACCOUNT_ID set to bypass the /memberships lookup (otherwise kv namespace create and d1 create fail with 403)
    4. cf-tunnel-setup.sh requires jq locally — added to the script header

Test plan

  • Copy wrangler.jsonc.example on a fresh clone, run npx wrangler kv namespace create AUTH_KV — should succeed without schema errors
  • Copy wrangler.jsonc.example for log-receiver, run npx wrangler d1 create openclaw-logs — should succeed without schema errors
  • Pull a fresh OpenClaw image and run build-openclaw.sh — confirm patch is applied and container starts with gosu working
  • Deploy with docker compose up -d — visit the domain and confirm no 520 errors (cloudflared can now reach the gateway port)

The upstream Dockerfile now contains "docker.io" in its LABEL metadata
(docker.io/library/node:22-bookworm), causing the old grep to return a
false positive and skip the gosu+Docker patch. The container then crashed
in the entrypoint with "gosu: command not found".

Grep for "gosu" instead — it is only present after the patch is applied.
…ples

Wrangler 4.71 validates the entire config before executing any subcommand,
including kv namespace create and d1 create. Empty string ("") for
kv_namespaces id and non-UUID strings for d1 database_id both fail
validation with a schema error before the create command can run.

Replace both placeholders with valid-format dummy values that pass schema
validation, so the user can run the create commands before filling in real
IDs. The playbook already documents updating these values after creation.
…reqs

Fresh deployment uncovered several setup gaps:

1. workers.dev subdomain must be registered before first deploy — wrangler
   exits immediately without a useful error if it hasn't been claimed.

2. CLOUDFLARE_API_TOKEN requires Workers Scripts:Edit, Workers KV
   Storage:Edit, and D1:Edit permissions in addition to Tunnel and DNS
   Edit. The previous list was incomplete, causing confusing 403 errors
   during kv namespace create and d1 create.

3. Multi-account tokens fail wrangler's /memberships lookup even when
   valid. Setting CLOUDFLARE_ACCOUNT_ID in .env bypasses the lookup.

4. cf-tunnel-setup.sh requires jq locally (not documented). Add it to
   the script header alongside CF_API_TOKEN.
With bridge networking, cloudflared's tunnel ingress routes to
localhost:PORT inside the cloudflared container, not the host where
openclaw gateway ports are published (127.0.0.1:PORT). This causes
Cloudflare 520 errors on first deploy.

Switch cloudflared to network_mode: host so localhost resolves to the
host's loopback, matching the port bindings in the openclaw container.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant