MallaDocs

Deployment

Environments, bindings, secrets, migrations and the deploy script on Cloudflare.

Developer guide

Six Workers, each with a staging and a production environment in its wrangler.jsonc. The top level of every config is the local dev and e2e setup and is never deployed. The full checklist, with resources, bindings and secrets, is in docs/DEPLOY.md.

Environments

WorkerStagingProduction
realtimemalla-realtime-stagingmalla-realtime
apimalla-api-stagingmalla-api
sitesmalla-sites-stagingmalla-sites
webmalla-web-stagingmalla-web
runnermalla-runner-stagingmalla-runner
mcpmalla-mcp-stagingmalla-mcp

Neon branches map to environments: dev backs staging, main backs production. Service bindings always point at the same environment.

Release

  1. Secrets

    Set each Worker’s secrets with wrangler secret put --env <env>. Shared values (internal key, realtime token secret) must match across Workers. Secrets are never set by scripts.

  2. Migrations

    Apply packages/db/migrations in order to the environment’s Neon branch before deploying an api that needs them. Migrations are forward-only.

    bash
    read -rs DATABASE_URL && export DATABASE_URL   # the branch's connection string
    pnpm --filter @malla/db db:migrate
    unset DATABASE_URL
    
  3. Deploy

    The script builds the workspace packages and the Nuxt app, then deploys in dependency order, so each service binding’s target exists first.

    bash
    pnpm deploy:check          # build and validate every Worker, upload nothing
    pnpm deploy:staging        # sh scripts/deploy.sh staging
    pnpm deploy:production     # sh scripts/deploy.sh production
    
    Deploy order
    realtime
    runner
    api
    mcp
    sites
    web
  4. Smoke check

    Load the app, sign in, open a site (the realtime socket connects), upload an image, publish to staging, submit a form, and watch the api cron with wrangler tail.

Rollback

  • A site: publishes are immutable, so rolling back is a pointer flip to an earlier publishId. No redeploy. Use Recent publishes in the editor's publish popover, or POST /sites/:siteId/rollback; see Roll back.
  • A Worker: roll back with Wrangler, in reverse deploy order when a change spans Workers. Secrets and bindings are not versioned with code.
  • The database: branch or snapshot main in Neon before a risky migration; restore it to undo.
  • Durable Object migrations cannot be rolled back; never revert a release past one.
bash
(cd apps/<app> && npx wrangler rollback --env <env>)
npx wrangler versions list --env <env>