Skip to content

Hosted deployment

The hosted application runs on Cloudflare Workers with D1, R2, static web assets, and Cloudflare Email Service. The application and API are served same-origin at https://app.commitmentdesk.com, with the API under /v1. The public documentation site at https://commitmentdesk.com is deployed separately; see documentation site.

Deployment is manual and owner-approved. Pull-request CI has no production credentials and cannot deploy.

Environment Worker D1 database R2 bucket Host
Development local Wrangler local D1 local R2 http://localhost:8787
Staging commitment-desk-api-staging commitment-desk-staging commitment-desk-attachments-staging https://app-staging.commitmentdesk.com
Production commitment-desk-api commitment-desk commitment-desk-attachments https://app.commitmentdesk.com

inbox.commitmentdesk.com is a permanent redirect to the application host and preserves path and query. See ADR 0011.

  • Cloudflare Workers Paid, which is required for arbitrary email recipients and included D1/R2 usage.
  • An account-owned Cloudflare API token scoped to commitmentdesk.com with Workers Scripts, Workers Routes, Workers R2 Storage, D1, Cloudflare Pages, Email Sending, DNS, SSL and Certificates, Zone Settings, Single Redirect, and read/analytics permissions.
  • The GitHub production environment with CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID secrets.
  • Cloudflare Email Service onboarding for commitmentdesk.com. See email delivery.

Never commit the token. Store it in the password manager and the protected GitHub environment.

Create remote resources once per environment:

Terminal window
pnpm --filter @commitment-desk/api exec wrangler d1 create commitment-desk-staging
pnpm --filter @commitment-desk/api exec wrangler d1 create commitment-desk
pnpm --filter @commitment-desk/api exec wrangler r2 bucket create commitment-desk-attachments-staging
pnpm --filter @commitment-desk/api exec wrangler r2 bucket create commitment-desk-attachments

Put the returned D1 ids into the matching env.staging and env.production blocks in apps/api/wrangler.jsonc. Keep the staging and production ids distinct.

Each Wrangler environment sets:

  • ENVIRONMENT=production so session cookies are Secure and HttpOnly.
  • WEB_BASE_URL to the environment’s own HTTPS origin.
  • EMAIL_FROM, EMAIL_FROM_NAME, and EMAIL_REPLY_TO.
  • The send_email binding restricted to no-reply@commitmentdesk.com.
  • The environment’s D1 and R2 bindings.
  • Workers Static Assets from apps/web/dist, with /v1 and /v1/* routed to the Worker first.

The Worker has no application secret bindings: sessions are random tokens stored hashed in D1, and API keys and webhook secrets are generated per tenant.

Build the web app first, then apply migrations before deploying the Worker:

Terminal window
pnpm --filter @commitment-desk/web build
pnpm --filter @commitment-desk/api exec wrangler d1 migrations apply DB --remote --env staging
pnpm --filter @commitment-desk/api exec wrangler d1 migrations apply DB --remote --env production

Migrations are ordered by filename in infra/cloudflare/migrations. A failed migration stops the deployment before traffic switches; fix forward or restore the previous Worker version as described under rollback.

Use the protected Deploy hosted app workflow from main, or run the equivalent commands:

Terminal window
pnpm --filter @commitment-desk/web build
pnpm --filter @commitment-desk/api exec wrangler d1 migrations apply DB --remote --env production
pnpm --filter @commitment-desk/api exec wrangler deploy --env production

The workflow requires the production environment and a typed confirmation. It records the commit and migration result, deploys the Worker and assets, and runs the synthetic smoke check.

  • app.commitmentdesk.com is a Worker custom domain attached by Wrangler.
  • app-staging.commitmentdesk.com is the staging custom domain.
  • inbox.commitmentdesk.com has a proxied placeholder DNS record and a Cloudflare Single Redirect rule to https://app.commitmentdesk.com, preserving path and query.
  • commitmentdesk.com is owned by the documentation Pages project, not the Worker.

Verify:

Terminal window
curl -fsS https://app.commitmentdesk.com/v1/health
curl -fsSI https://inbox.commitmentdesk.com/some/path?q=1

The redirect must return a 301 to https://app.commitmentdesk.com/some/path?q=1.

The smoke script verifies health, reviewer session, capture submission, parcel review, export, and a signed webhook delivery against a dedicated synthetic tenant. It uses no client data:

Terminal window
CD_SMOKE_API_URL=https://app.commitmentdesk.com pnpm smoke:hosted

A failed smoke check blocks the deployment’s success signal.

Production runs with Workers observability enabled. The scheduled health workflow checks /v1/health, recent 5xx responses, webhook delivery failures, and storage growth, and opens or updates an operator issue on sustained failure. Logs identify tenant and request identifiers where appropriate and never contain capture payloads, attachment contents, tokens, or credentials.

  • D1 supports Time Travel and export. Export before risky migrations.
  • Enable R2 object versioning or replication and keep the bucket private.
  • Rehearse restore into staging and run the smoke test against the restored environment before accepting client data.
  1. Stop the deployment before traffic switches if a migration fails.
  2. Roll back to the previous Worker version from the Cloudflare dashboard or wrangler rollback.
  3. Do not drop production tables. Fix forward with a new migration when possible.
  4. Re-run the smoke check and record the incident and version.

Use scripts/seed-remote.mjs with the target environment to create a normal synthetic demo tenant and explicit demo memberships. Keep the generated API key in the secret manager, never in the repository. Demo data is isolated by tenant and contains no real taxpayer information. A public demo host with automated reset remains a separate change.