# Deploy to Cloudflare

StatusBeam runs entirely on Cloudflare: a Cron Worker for checks and an Astro
site for the page, backed by D1 (time-series) and KV (current snapshot). The repo
ships a scripted path and a manual one — the outline below mirrors the repo's
`DEPLOYMENT.md`, which is the authoritative reference.
**Tip:** Fastest path: `bun run setup` runs the scripted provisioning. The steps below
  are the manual equivalent.

## Steps

1. **Provision D1 + KV.** Create the D1 database and KV namespace in your
   Cloudflare account.

2. **Wire the resource IDs** into each app's `wrangler.jsonc` (the `database_id`
   and KV `id` placeholders).

3. **Write your config** — see [Configuration](/guides/configuration/).

4. **Apply the D1 schema** to create the time-series and incident tables.

5. **Upload the config to KV** under the `config` key.

6. **Set secrets** for optional integrations (Slack/webhook URLs live inside the
   KV `config`, cache-purge credentials as Worker secrets).

7. **Deploy.**

   ```bash
   bun run deploy
   ```

   This deploys the check Worker and the web app to Cloudflare.

8. **Verify** the first cron run has populated D1/KV and the page renders.

## Deploying these docs

This documentation site is a separate app (`apps/docs`). It is a fully static
Starlight build deployed to a **Cloudflare Pages** project (`statusbeam-docs`) —
no D1/KV, no server adapter:

```bash
bun run --filter '@statusbeam/docs' deploy
```

The site is reached at **`docs.statusbeam.dev`** (a custom domain on the Pages
project), while its bundled assets (`_astro/*` JS, CSS, fonts) load from the
project's own **`statusbeam-docs.pages.dev`** origin. That split is configured via
Astro's [`build.assetsPrefix`](https://docs.astro.build/en/reference/configuration-reference/#buildassetsprefix)
in `astro.config.ts`; the cross-origin assets are made CORS-readable by
`public/_headers`.
**Note:** One-time setup on Cloudflare: create the Pages project
  (`bunx wrangler pages project create statusbeam-docs --production-branch main`)
  and attach the `docs.statusbeam.dev` custom domain in the dashboard
  (Pages → your project → Custom domains). The deploy token needs the
  **Cloudflare Pages: Edit** permission.