Cloudflare Workers deployment
Proxy and Admin are separate Workers sharing one D1 database (binding DB). This is OctaFuse’s default production path—individuals and light traffic can usually deploy and run within the Workers / D1 free tier.
One-command bootstrap (recommended)
Section titled “One-command bootstrap (recommended)”git clone https://github.com/OctaFuse/octafuse-gateway.gitcd octafuse-gatewaynpm installnpx wrangler loginnpm run bootstrap:cloudflareThe script will: create or reuse D1 → remote migrate → deploy Proxy / Admin → put ADMIN_PASSWORD → print downstream GATEWAY_* hints.
Later releases:
npm run deploy:cloudflare -- <instance> --migrate # include when new D1 SQL landsnpm run deploy:cloudflare -- <instance> # redeploy onlyTry locally without deploying: Quick start · local.
Configuration model (deeper)
Section titled “Configuration model (deeper)”| Layer | Role |
|---|---|
packages/*/wrangler.base.jsonc | Committed templates (no production database_id) |
packages/proxy/wrangler.jsonc, etc. | Generated (gitignored) by gen:wrangler |
cloudflare-worker/example.env | Dev demo canonical config (committed) |
cloudflare-worker/<instance>.env | Production/private (gitignored); or Dashboard Build variables only |
gen-wrangler reads environment variables (process.env) only.
Other paths
Section titled “Other paths”| Path | When |
|---|---|
| Local dev | Laptop + local D1 (Quick start) |
| Dev demo | Public test test-api.octafuse.dev (example.env + CLI) |
| Workers Builds | Connect to Git auto-deploy (D1 migrations still manual) |
Returning to local after remote deploys
Section titled “Returning to local after remote deploys”After deploy:* or db:migrate:remote, generated wrangler.jsonc may include the remote D1_DATABASE_ID. Before local development, run npm run gen:wrangler from a shell without D1_DATABASE_ID exported, then restart dev:proxy / dev:admin.
Workers Builds commands (optional)
Section titled “Workers Builds commands (optional)”Leave Root directory empty (monorepo root). npm ci → postinstall → gen:wrangler.
| Worker | Build command | Deploy command |
|---|---|---|
| Proxy | npm ci && npm run gen:wrangler | npm run deploy -w @octafuse/proxy |
| Admin | npm ci && npm run gen:wrangler && npm run build:cf -w @octafuse/admin | cd packages/admin && npx opennextjs-cloudflare deploy |
Secrets and downstream
Section titled “Secrets and downstream”ADMIN_PASSWORD: set by bootstrap; ornpx wrangler secret put ADMIN_PASSWORD --name <ADMIN_WORKER_NAME>.- Downstream:
GATEWAY_URL(Proxy),GATEWAY_MASTER_URL(Admin),GATEWAY_MASTER_KEY(D1system_config.MASTER_KEY). Rotate if still the seedsk-dev-admin-key.
vs Docker
Section titled “vs Docker”- Default / edge / no server to babysit → this page (Cloudflare).
- Data residency, VPC, BYO Postgres/MySQL → Docker.