opencode/services/data/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

43 lines
2 KiB
TypeScript

import { bindings, defineConfig, triggers } from "cf/config"
import { LOCALES } from "../../packages/data/app/src/lib/language"
import { ogWorkerName } from "./og.config"
import { stage, stageAccount, stageHost } from "./stage"
// The data site (packages/data/app, SolidStart) at /data and /<locale>/data on the main host. `--mode dev` deploys
// opencode-data-dev on dev.opencode.ai and `--mode production` opencode-data-production on opencode.ai; any other
// mode throws (stage.ts). The routes are its only way in: it has no custom domain or workers.dev URL. An exact `/data`
// pattern misses `/data?query`, so each pattern is a `/data*` prefix, and route patterns can't wildcard the middle of
// a path, hence one per locale.
// script/build.ts builds this, og.config.ts and sync.config.ts into one Build Output tree.
export default defineConfig(({ mode }) => {
const current = stage(mode)
const host = stageHost(current)
return {
// Anomaly
accountId: stageAccount(current),
worker: {
name: `opencode-data-${current}`,
compatibilityDate: "2026-07-25",
// The Nitro server is built with node compatibility, which also copies string bindings into process.env
// (packages/data/core/src/resource.ts).
compatibilityFlags: ["nodejs_compat"],
env: {
ASSETS: bindings.assets(),
// The private Worker that renders Open Graph images (og.config.ts).
OG_WORKER: bindings.worker({ worker: ogWorkerName(mode) }),
STAGE: bindings.text(current),
PUBLIC_URL: bindings.text(`https://${host}/data`),
// Set from AWS Secrets Manager (opencode/<stage>/DATA_*) by the deploy job.
DATA_DATABASE_HOST: bindings.secret(),
DATA_DATABASE_USERNAME: bindings.secret(),
DATA_DATABASE_PASSWORD: bindings.secret(),
},
triggers: ["data", ...LOCALES.map((locale) => `${locale}/data`)].map((prefix) =>
triggers.fetch({ pattern: `${host}/${prefix}*`, zone: host }),
),
workersDev: false,
previewUrls: false,
observability: { enabled: true },
},
}
})