Skip to content
356 linesCodeBlameRaw
1// Everything g1t deploys to Cloudflare, in one place. Read by
2// scripts/deploy.mjs (plan, deploy), deploy/self-host/configs.mjs (what a
3// self-hosted installation runs) and the tests in scripts/deploy/.
4// docs/DEPLOYING.md explains each field and how to add a unit.
5//
6// What is written here is what the Wrangler configs cannot say. The rest is
7// read from each unit's wrangler.jsonc, never copied: its D1 databases and
8// migrations, the services it binds to, its KV, R2, queues and routes. The
9// shared crates and packages a unit is built from are read from Cargo's and
10// npm's workspace metadata. `worker` and `d1` are written here too, so the
11// file reads as an inventory, and a test checks they match the configs.
12{
13 // Deployed in this order. A stage starts only when the one before it
14 // succeeded. A unit binds only to units in its own stage or an earlier
15 // one (a test checks it), so new code never calls a service that has
16 // not shipped yet. Within a stage, units go out in parallel.
17 //
18 // migrations: every pending D1 migration, before any code.
19 // core: the services, reached through service bindings.
20 // edge: public endpoints other than the site: API, MCP, g1t.page, status
21 // (models is public too, but in core: agents binds to it).
22 // front: the site, sudo and the docs.
23 "stages": ["migrations", "core", "edge", "front"],
24
25 // Names for the resources the configs refer to by id, for setup
26 // commands and the docs. A test checks every KV id in a config is here.
27 "resources": {
28 "kv": {
29 "16a4232cb746418db53782aa068be693": "g1t-actions-blobs",
30 "e627b571f07047e187c03e1fc2b3bbdd": "g1t-avatars",
31 "14bc5c233d4c46a5bbf23b5367cce5fd": "g1t-domains",
32 "be765052d0124c2a935b3db4dff99f1f": "g1t-repos-git-cache"
33 }
34 },
35
36 // Each deployable unit, by short name (`--only events,web`).
37 //
38 // kind: rust-worker (worker-build), ts-worker (Wrangler bundles it),
39 // react-router (vite build first), astro (astro build first).
40 // secrets: names only; set with `npx wrangler secret put NAME` in its folder.
41 // setup: one-time steps no config can say, for a first deploy.
42 // self_host: what deploy/self-host does with it: "run" (in the one
43 // workerd), "off" (bound to the off Worker), "separate" (a
44 // process of its own), or "none".
45 // inputs: files outside its folder it is built from that no workspace
46 // metadata names (a test finds such imports).
47 // image: a Containers image (docs/DEPLOYING.md, "The runner's images"):
48 // dockerfile the image a deploy ships: the base plus the binary
49 // crate the crate that binary is built from (and what it uses)
50 // base { context: the base's folder, lock: the file that
51 // records the base that was pushed }; the base is
52 // rebuilt only when its folder changes
53 // repository where both are pushed in Cloudflare's registry
54 "units": {
55 "events": {
56 "path": "services/events",
57 "kind": "rust-worker",
58 "worker": "g1t-events",
59 "d1": { "database": "g1t-events", "migrations": "migrations" },
60 "stage": "core",
61 "secrets": [],
62 "setup": [
63 "The dead-letter queue every queue consumer sends what it gave up on to, before any unit that names it deploys: npx wrangler queues create g1t-events-dlq"
64 ],
65 "self_host": "run"
66 },
67 "identity": {
68 "path": "services/identity",
69 "kind": "rust-worker",
70 "worker": "g1t-identity",
71 "d1": { "database": "g1t", "migrations": "migrations" },
72 "stage": "core",
73 "secrets": ["GITHUB_APP_CLIENT_SECRET", "IDENTITY_KEY"],
74 "setup": ["Email Sending on g1t.sh (the EMAIL binding)"],
75 "self_host": "run"
76 },
77 "repos": {
78 "path": "services/repos",
79 "kind": "rust-worker",
80 "worker": "g1t-repos",
81 "d1": { "database": "g1t-repos", "migrations": "migrations" },
82 "stage": "core",
83 "secrets": ["REPOS_KEY"],
84 "setup": [
85 "The Artifacts namespace `g1t` (the ARTIFACTS binding)",
86 "The R2 bucket `g1t-git-packs` (GIT_PACKS) with its lifecycle rule: `npx wrangler r2 bucket create g1t-git-packs`, then `npx wrangler r2 bucket lifecycle add g1t-git-packs expire-packs packs/ --expire-days 7 --abort-multipart-days 1`",
87 "The R2 bucket for nightly backups: npx wrangler r2 bucket create g1t-backups"
88 ],
89 "self_host": "run"
90 },
91 "work": {
92 "path": "services/work",
93 "kind": "rust-worker",
94 "worker": "g1t-work",
95 "d1": { "database": "g1t-work", "migrations": "migrations" },
96 "stage": "core",
97 "secrets": [],
98 "self_host": "run"
99 },
100 "search": {
101 "path": "services/search",
102 "kind": "rust-worker",
103 "worker": "g1t-search",
104 "d1": { "database": "g1t-search", "migrations": "migrations" },
105 "stage": "core",
106 "secrets": [],
107 "self_host": "run"
108 },
109 "projects": {
110 "path": "services/projects",
111 "kind": "ts-worker",
112 "worker": "g1t-projects",
113 "d1": { "database": "g1t-projects", "migrations": "migrations" },
114 "stage": "core",
115 "secrets": [],
116 "self_host": "run"
117 },
118 "chat": {
119 "path": "services/chat",
120 "kind": "ts-worker",
121 "worker": "g1t-chat",
122 "d1": { "database": "g1t-chat", "migrations": "migrations" },
123 "stage": "core",
124 "secrets": [],
125 "setup": [
126 "The D1 database, before the first deploy: npx wrangler d1 create g1t-chat, then put its id in services/chat/wrangler.jsonc"
127 ],
128 "self_host": "run"
129 },
130 "notify": {
131 "path": "services/notify",
132 "kind": "ts-worker",
133 "worker": "g1t-notify",
134 // No D1: each person's feed keeps its own state in its Durable
135 // Object's SQLite storage.
136 "stage": "core",
137 // The private half of the VAPID key pair browser pushes are signed
138 // with; without it, notifications are live in open tabs only.
139 "secrets": ["VAPID_PRIVATE_KEY"],
140 "setup": [
141 "The VAPID key pair for browser push: `node scripts/ops/vapid-keys.mjs` prints both halves and stores nothing. Put the public half in VAPID_PUBLIC_KEY in services/notify/wrangler.jsonc, and the private half with `npx wrangler secret put VAPID_PRIVATE_KEY` in services/notify"
142 ],
143 "self_host": "run"
144 },
145 "agents": {
146 "path": "services/agents",
147 "kind": "ts-worker",
148 "worker": "g1t-agents",
149 "d1": { "database": "g1t-agents", "migrations": "migrations" },
150 "stage": "core",
151 "secrets": [],
152 "setup": [
153 "The D1 database, before the first deploy: npx wrangler d1 create g1t-agents, then put its id in services/agents/wrangler.jsonc"
154 ],
155 // Replies route and gate model work exactly as runs do, with the
156 // runner's own modules: its routing policy and who may use hosted models.
157 "inputs": ["services/runner/src/model-env.ts", "services/runner/src/hosted.ts"],
158 "self_host": "run"
159 },
160 "billing": {
161 "path": "services/billing",
162 "kind": "rust-worker",
163 "worker": "g1t-billing",
164 "d1": { "database": "g1t-billing", "migrations": "migrations" },
165 "stage": "core",
166 "secrets": ["STRIPE_SECRET_KEY", "STRIPE_WEBHOOK_SECRET", "CLOUDFLARE_USAGE_TOKEN"],
167 "self_host": "run"
168 },
169 "integrations": {
170 "path": "services/integrations",
171 "kind": "rust-worker",
172 "worker": "g1t-integrations",
173 "d1": { "database": "g1t-integrations", "migrations": "migrations" },
174 "stage": "core",
175 "secrets": ["INTEGRATIONS_KEY", "GITHUB_APP_PRIVATE_KEY", "GITHUB_APP_WEBHOOK_SECRET"],
176 "self_host": "run"
177 },
178 "webhooks": {
179 "path": "services/webhooks",
180 "kind": "rust-worker",
181 "worker": "g1t-webhooks",
182 "d1": { "database": "g1t-webhooks", "migrations": "migrations" },
183 "stage": "core",
184 "secrets": ["WEBHOOKS_KEY"],
185 "self_host": "run"
186 },
187 "actions": {
188 "path": "services/actions",
189 "kind": "rust-worker",
190 "worker": "g1t-actions",
191 "d1": { "database": "g1t-actions", "migrations": "migrations" },
192 "stage": "core",
193 "secrets": ["ACTIONS_KEY"],
194 "self_host": "run"
195 },
196 "packages": {
197 "path": "services/packages",
198 "kind": "rust-worker",
199 "worker": "g1t-packages",
200 "d1": { "database": "g1t-packages", "migrations": "migrations" },
201 "stage": "core",
202 "secrets": ["PACKAGES_TOKEN_SECRET", "R2_ACCESS_KEY_ID", "R2_SECRET_ACCESS_KEY"],
203 "setup": [
204 "The D1 database: npx wrangler d1 create g1t-packages, its id in services/packages/wrangler.jsonc",
205 "The R2 bucket for packages' files: npx wrangler r2 bucket create g1t-packages",
206 "The events queue: npx wrangler queues create g1t-events-packages",
207 "For signed downloads: an R2 API token with read access to g1t-packages, as R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY"
208 ],
209 "self_host": "run"
210 },
211 "security": {
212 "path": "services/security",
213 "kind": "rust-worker",
214 "worker": "g1t-security",
215 "d1": { "database": "g1t-security", "migrations": "migrations" },
216 "stage": "core",
217 "secrets": [],
218 "self_host": "run"
219 },
220 "deployments": {
221 "path": "services/deployments",
222 "kind": "ts-worker",
223 "worker": "g1t-deployments",
224 "d1": { "database": "g1t-deployments", "migrations": "migrations" },
225 "stage": "core",
226 "secrets": ["CLOUDFLARE_API_TOKEN"],
227 "setup": [
228 "Workers for Platforms, and the dispatch namespace: scripts/setup-deployments.sh",
229 "Custom domains (Cloudflare for SaaS on g1t.page): scripts/setup-custom-domains.sh"
230 ],
231 "self_host": "run"
232 },
233 "runner": {
234 "path": "services/runner",
235 "kind": "ts-worker",
236 "worker": "g1t-runner",
237 "stage": "core",
238 "secrets": ["AI_GATEWAY_TOKEN"],
239 "setup": [
240 "Containers on the account; Docker on the machine that builds a new image",
241 "The base image, once: node scripts/deploy.mjs build-base"
242 ],
243 "image": {
244 "dockerfile": "services/runner/Dockerfile",
245 // The binary the image adds to its base (scripts/build-runner.mjs).
246 "crate": "g1t-runner",
247 "base": { "context": "services/runner/base", "lock": "services/runner/base.json" },
248 "repository": "g1t-runner"
249 },
250 "self_host": "off"
251 },
252 "context": {
253 "path": "services/context",
254 "kind": "ts-worker",
255 "worker": "g1t-context",
256 "d1": { "database": "g1t-context", "migrations": "migrations" },
257 "stage": "core",
258 "secrets": [],
259 "setup": [
260 "The Vectorize index: npx wrangler vectorize create g1t-context --dimensions=768 --metric=cosine, with metadata indexes on workspace, kind, project and private"
261 ],
262 "self_host": "off"
263 },
264 "og": {
265 "path": "services/og",
266 "kind": "ts-worker",
267 "worker": "g1t-og",
268 "stage": "core",
269 "secrets": [],
270 "setup": ["Browser Rendering on the account (the BROWSER binding)"],
271 // The roadmap cards read the site's roadmap.
272 "inputs": ["apps/web/app/lib/roadmap.ts"],
273 "self_host": "none"
274 },
275 "api": {
276 "path": "apps/api",
277 "kind": "rust-worker",
278 "worker": "g1t-api",
279 "stage": "edge",
280 // ACTIONS_OIDC_KEY signs workflow jobs' OIDC tokens; without it the
281 // issuer answers 404 and jobs are not offered tokens.
282 // ACTIONS_OIDC_KEY_PREVIOUS only while rotating. docs/DEPLOYING.md.
283 "secrets": ["ACTIONS_OIDC_KEY"],
284 "setup": [
285 "The OIDC signing key for workflow jobs: an RSA key made with `openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048`, stored with `npx wrangler secret put ACTIONS_OIDC_KEY` (docs/DEPLOYING.md, \"OIDC tokens for workflow jobs\")",
286 "The actions cache bucket's lifecycle rule limited to `c/`, so artifacts under `a/` are kept their retention-days (docs/DEPLOYING.md)"
287 ],
288 "self_host": "separate"
289 },
290 "models": {
291 "path": "services/models",
292 "kind": "ts-worker",
293 "worker": "g1t-models",
294 // Core, though it is public at models.g1t.sh: the agents service
295 // reaches it by service binding for chat replies. It binds only to
296 // core services itself.
297 "stage": "core",
298 "secrets": ["AI_GATEWAY_TOKEN"],
299 "setup": ["The AI Gateway `g1t`"],
300 // Not run self-hosted, but bound to the off Worker: agents binds to it.
301 "self_host": "off"
302 },
303 "pages": {
304 "path": "services/pages",
305 "kind": "ts-worker",
306 "worker": "g1t-pages",
307 "stage": "edge",
308 "secrets": [],
309 "setup": ["A proxied wildcard DNS record on g1t.page (`*`, AAAA 100::): scripts/setup-deployments.sh"],
310 "self_host": "none"
311 },
312 "status": {
313 "path": "apps/status",
314 "kind": "ts-worker",
315 "worker": "g1t-status",
316 "d1": { "database": "g1t-status", "migrations": "migrations" },
317 "stage": "edge",
318 "secrets": ["STATUS_SECRET"],
319 "setup": ["Email Sending on g1t.sh (the EMAIL binding)"],
320 "self_host": "separate"
321 },
322 "web": {
323 "path": "apps/web",
324 "kind": "react-router",
325 "worker": "g1t",
326 "stage": "front",
327 // USERCONTENT_KEY signs the short-lived addresses of private
328 // repositories' files on g1tusercontent.com; without it they are
329 // served from g1t.sh instead.
330 "secrets": ["USERCONTENT_KEY"],
331 "setup": [
332 "The R2 bucket g1t-downloads, for the self-hosted runner's releases: npx wrangler r2 bucket create g1t-downloads",
333 "The zone g1tusercontent.com on the account; the Worker's custom domain on it is made by the deploy",
334 "The key for private files' addresses: `node -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\" | npx wrangler secret put USERCONTENT_KEY` in apps/web"
335 ],
336 "self_host": "run"
337 },
338 "sudo": {
339 "path": "apps/sudo",
340 "kind": "react-router",
341 "worker": "g1t-sudo",
342 "stage": "front",
343 "secrets": [],
344 "setup": ["A Cloudflare Access application on sudo.g1t.sh; its AUD tag is ACCESS_AUD"],
345 "self_host": "none"
346 },
347 "docs": {
348 "path": "apps/docs",
349 "kind": "astro",
350 "worker": "g1t-docs",
351 "stage": "front",
352 "secrets": [],
353 "self_host": "none"
354 }
355 }
356}