opencode/services/site/cloudflare.config.ts
Dax 33123b1c42
Some checks are pending
bot-nix-hashes / hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Waiting to run
bot-nix-hashes / hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Waiting to run
bot-nix-hashes / hash (macos-latest, aarch64-darwin) (push) Waiting to run
bot-nix-hashes / compute (push) Blocked by required conditions
bot-nix-hashes / publish (push) Blocked by required conditions
check-nix / nix-eval (push) Waiting to run
Process daemon / Miri (callback ownership) (push) Waiting to run
Process daemon / Core (macos-15) (push) Waiting to run
Process daemon / Core (ubuntu-22.04) (push) Waiting to run
Process daemon / Windows (arm64) (push) Waiting to run
Process daemon / Windows (x64) (push) Waiting to run
check / typecheck (push) Waiting to run
deploy-files / files-build (push) Waiting to run
deploy-files / files-deploy (push) Blocked by required conditions
deploy-site / site-build (push) Waiting to run
deploy-site / site-deploy (push) Blocked by required conditions
deploy / legacy-build (push) Waiting to run
deploy / legacy-deploy (push) Blocked by required conditions
deploy / data-build (push) Waiting to run
deploy / data-deploy (push) Blocked by required conditions
ci: deploy dev workers in anomaly-dev (#63379)
2026-11-11 16:17:46 -05:00

56 lines
2.5 KiB
TypeScript

import { bindings, defineConfig, triggers } from "cf/config"
import { docsSets } from "./src/docs/config"
// The opencode.ai website (SolidStart). `--mode dev` deploys opencode-site-dev on dev.opencode.ai;
// any other mode deploys opencode-site-production on opencode.ai. It is the catch-all: more specific
// routes on the zone (Console, inference, changelog, update, files, stats, …) keep beating it. It
// also serves the V2 docs at /docs (src/docs).
//
// Production takes no routes until the go-live flips this switch (the `production` branch is shared
// with every other service, so an unrelated push must not take the domain).
const productionOwnsRoot = true
export default defineConfig(({ mode }) => {
const dev = mode === "dev"
const host = dev ? "dev.opencode.ai" : "opencode.ai"
return {
// Anomaly
accountId: dev ? "d8e944f537ceef3f06a5bd3aec1d7a53" : "15d29c8639fd3733b1b5486a2acfd968",
worker: {
name: dev ? "opencode-site-dev" : "opencode-site-production",
compatibilityDate: "2026-07-25",
// The Nitro server is built with node compatibility (vite.config.ts).
compatibilityFlags: ["nodejs_compat"],
assets: {
htmlHandling: "drop-trailing-slash",
// Docs pages answer with HTML or Markdown from one URL, and a /docs URL without a V2 page
// goes to the V1 docs, so the Worker picks the asset (src/docs/middleware.ts). The docs' own
// files (search, stylesheets, images, llms.txt, …) are plain assets.
runWorkerFirst: docsSets.flatMap((set) => [
set.base.slice(0, -1),
`${set.base}*`,
...set.files.map((file) => `!${set.base}${file}${file.includes(".") ? "" : "/*"}`),
]),
},
env: {
ASSETS: bindings.assets(),
STAGE: bindings.text(dev ? "dev" : "production"),
},
triggers:
dev || productionOwnsRoot
? [
triggers.fetch({ pattern: host, zone: host }),
triggers.fetch({ pattern: `${host}/*`, zone: host }),
]
: [],
// The bare host is a custom domain (it also supplies the DNS record), and cf detaches any domain
// not listed here. docs.<host> is the old docs host: the Worker sends its URLs to the same path
// on the V1 docs at /v1/docs.
domains: [host, `docs.${host}`],
workersDev: false,
previewUrls: false,
// Workers Logs: requests, errors and console output, searchable in the Cloudflare dashboard.
observability: { enabled: true },
},
}
})