Skip to content

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.

Terminal window
git clone https://github.com/OctaFuse/octafuse-gateway.git
cd octafuse-gateway
npm install
npx wrangler login
npm run bootstrap:cloudflare

The script will: create or reuse D1 → remote migrate → deploy Proxy / Admin → put ADMIN_PASSWORD → print downstream GATEWAY_* hints.

Later releases:

Terminal window
npm run deploy:cloudflare -- <instance> --migrate # include when new D1 SQL lands
npm run deploy:cloudflare -- <instance> # redeploy only

Try locally without deploying: Quick start · local.

LayerRole
packages/*/wrangler.base.jsoncCommitted templates (no production database_id)
packages/proxy/wrangler.jsonc, etc.Generated (gitignored) by gen:wrangler
cloudflare-worker/example.envDev demo canonical config (committed)
cloudflare-worker/<instance>.envProduction/private (gitignored); or Dashboard Build variables only

gen-wrangler reads environment variables (process.env) only.

PathWhen
Local devLaptop + local D1 (Quick start)
Dev demoPublic test test-api.octafuse.dev (example.env + CLI)
Workers BuildsConnect to Git auto-deploy (D1 migrations still manual)

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.

Leave Root directory empty (monorepo root). npm cipostinstallgen:wrangler.

WorkerBuild commandDeploy command
Proxynpm ci && npm run gen:wranglernpm run deploy -w @octafuse/proxy
Adminnpm ci && npm run gen:wrangler && npm run build:cf -w @octafuse/admincd packages/admin && npx opennextjs-cloudflare deploy
  • ADMIN_PASSWORD: set by bootstrap; or npx wrangler secret put ADMIN_PASSWORD --name <ADMIN_WORKER_NAME>.
  • Downstream: GATEWAY_URL (Proxy), GATEWAY_MASTER_URL (Admin), GATEWAY_MASTER_KEY (D1 system_config.MASTER_KEY). Rotate if still the seed sk-dev-admin-key.
  • Default / edge / no server to babysit → this page (Cloudflare).
  • Data residency, VPC, BYO Postgres/MySQLDocker.