Skip to content

Deployment

Deploy to Cloudflare

  1. Ensure Cloudflare resources exist

    Follow Cloudflare Setup to create your D1 database, R2 bucket, and KV namespace.

  2. Set secrets

    Terminal window
    wrangler secret put AUTH_JWT_SECRET

    For OIDC auth:

    Terminal window
    wrangler secret put OIDC_ISSUER
    wrangler secret put OIDC_AUDIENCE
  3. Run remote migrations

    Terminal window
    wrangler d1 migrations apply alokon-db --remote
  4. Build and deploy

    Terminal window
    yarn deploy

    This runs yarn build (Vite + Wrangler bundle) then wrangler deploy.

What gets deployed

  • Workersrc/server/index.ts bundled by Wrangler
  • Static assetsdist/ (React SPA) uploaded to Cloudflare’s asset storage and served via the STATIC_ASSETS binding

The Worker serves API routes at /api/* and falls back to the SPA index.html for all other paths.

Environment-specific deployments

Use Wrangler environments to deploy to multiple stages:

wrangler.jsonc
"env": {
"staging": {
"name": "alokon-staging",
"vars": {
"ENVIRONMENT": "staging"
}
}
}

Deploy to staging:

Terminal window
wrangler deploy --env staging

Continuous deployment

A typical GitHub Actions workflow:

name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build
working-directory: apps/alokon
- run: yarn wrangler deploy
working-directory: apps/alokon
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

Custom domain

In the Cloudflare dashboard:

  1. Go to Workers & Pages → alokon → Settings → Triggers
  2. Under Custom Domains, click Add Custom Domain
  3. Enter your domain (e.g. cms.example.com)
  4. Cloudflare automatically provisions an SSL certificate

Updating

To deploy an update:

Terminal window
git pull
yarn install
cd apps/alokon
yarn deploy

If there are new migrations:

Terminal window
wrangler d1 migrations apply alokon-db --remote

Then deploy.