g1t/deploy/stack.jsonc

292 lines10,350 bytesCodeBlame
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, models, g1t.page, status.
21 // front: the site, sudo and the docs.
22 "stages": ["migrations", "core", "edge", "front"],
23
24 // Names for the resources the configs refer to by id, for setup
25 // commands and the docs. A test checks every KV id in a config is here.
26 "resources": {
27 "kv": {
28 "16a4232cb746418db53782aa068be693": "g1t-actions-blobs",
29 "e627b571f07047e187c03e1fc2b3bbdd": "g1t-avatars",
30 "14bc5c233d4c46a5bbf23b5367cce5fd": "g1t-domains",
31 "be765052d0124c2a935b3db4dff99f1f": "g1t-repos-git-cache"
32 }
33 },
34
35 // Each deployable unit, by short name (`--only events,web`).
36 //
37 // kind: rust-worker (worker-build), ts-worker (Wrangler bundles it),
38 // react-router (vite build first), astro (astro build first).
39 // secrets: names only; set with `npx wrangler secret put NAME` in its folder.
40 // setup: one-time steps no config can say, for a first deploy.
41 // self_host: what deploy/self-host does with it: "run" (in the one
42 // workerd), "off" (bound to the off Worker), "separate" (a
43 // process of its own), or "none".
44 // inputs: files outside its folder it is built from that no workspace
45 // metadata names (a test finds such imports).
46 // image: a Containers image (docs/DEPLOYING.md, "The runner's images"):
47 // dockerfile the image a deploy ships: the base plus the binary
48 // crate the crate that binary is built from (and what it uses)
49 // base { context: the base's folder, lock: the file that
50 // records the base that was pushed }; the base is
51 // rebuilt only when its folder changes
52 // repository where both are pushed in Cloudflare's registry
53 "units": {
54 "events": {
55 "path": "services/events",
56 "kind": "rust-worker",
57 "worker": "g1t-events",
58 "d1": { "database": "g1t-events", "migrations": "migrations" },
59 "stage": "core",
60 "secrets": [],
61 "self_host": "run"
62 },
63 "identity": {
64 "path": "services/identity",
65 "kind": "rust-worker",
66 "worker": "g1t-identity",
67 "d1": { "database": "g1t", "migrations": "migrations" },
68 "stage": "core",
69 "secrets": ["GITHUB_APP_CLIENT_SECRET", "IDENTITY_KEY"],
70 "setup": ["Email Sending on g1t.sh (the EMAIL binding)"],
71 "self_host": "run"
72 },
73 "repos": {
74 "path": "services/repos",
75 "kind": "rust-worker",
76 "worker": "g1t-repos",
77 "d1": { "database": "g1t-repos", "migrations": "migrations" },
78 "stage": "core",
79 "secrets": ["REPOS_KEY"],
80 "setup": [
81 "The Artifacts namespace `g1t` (the ARTIFACTS binding)",
82 "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`",
83 "The R2 bucket for nightly backups: npx wrangler r2 bucket create g1t-backups"
84 ],
85 "self_host": "run"
86 },
87 "work": {
88 "path": "services/work",
89 "kind": "rust-worker",
90 "worker": "g1t-work",
91 "d1": { "database": "g1t-work", "migrations": "migrations" },
92 "stage": "core",
93 "secrets": [],
94 "self_host": "run"
95 },
96 "search": {
97 "path": "services/search",
98 "kind": "rust-worker",
99 "worker": "g1t-search",
100 "d1": { "database": "g1t-search", "migrations": "migrations" },
101 "stage": "core",
102 "secrets": [],
103 "self_host": "run"
104 },
105 "projects": {
106 "path": "services/projects",
107 "kind": "ts-worker",
108 "worker": "g1t-projects",
109 "d1": { "database": "g1t-projects", "migrations": "migrations" },
110 "stage": "core",
111 "secrets": [],
112 "self_host": "run"
113 },
114 "billing": {
115 "path": "services/billing",
116 "kind": "rust-worker",
117 "worker": "g1t-billing",
118 "d1": { "database": "g1t-billing", "migrations": "migrations" },
119 "stage": "core",
120 "secrets": ["STRIPE_SECRET_KEY", "STRIPE_WEBHOOK_SECRET", "CLOUDFLARE_USAGE_TOKEN"],
121 "self_host": "run"
122 },
123 "integrations": {
124 "path": "services/integrations",
125 "kind": "rust-worker",
126 "worker": "g1t-integrations",
127 "d1": { "database": "g1t-integrations", "migrations": "migrations" },
128 "stage": "core",
129 "secrets": ["INTEGRATIONS_KEY", "GITHUB_APP_PRIVATE_KEY", "GITHUB_APP_WEBHOOK_SECRET"],
130 "self_host": "run"
131 },
132 "webhooks": {
133 "path": "services/webhooks",
134 "kind": "rust-worker",
135 "worker": "g1t-webhooks",
136 "d1": { "database": "g1t-webhooks", "migrations": "migrations" },
137 "stage": "core",
138 "secrets": ["WEBHOOKS_KEY"],
139 "self_host": "run"
140 },
141 "actions": {
142 "path": "services/actions",
143 "kind": "rust-worker",
144 "worker": "g1t-actions",
145 "d1": { "database": "g1t-actions", "migrations": "migrations" },
146 "stage": "core",
147 "secrets": ["ACTIONS_KEY"],
148 "self_host": "run"
149 },
150 "packages": {
151 "path": "services/packages",
152 "kind": "rust-worker",
153 "worker": "g1t-packages",
154 "d1": { "database": "g1t-packages", "migrations": "migrations" },
155 "stage": "core",
156 "secrets": ["PACKAGES_TOKEN_SECRET", "R2_ACCESS_KEY_ID", "R2_SECRET_ACCESS_KEY"],
157 "setup": [
158 "The D1 database: npx wrangler d1 create g1t-packages, its id in services/packages/wrangler.jsonc",
159 "The R2 bucket for packages' files: npx wrangler r2 bucket create g1t-packages",
160 "The events queue: npx wrangler queues create g1t-events-packages",
161 "For signed downloads: an R2 API token with read access to g1t-packages, as R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY"
162 ],
163 "self_host": "run"
164 },
165 "security": {
166 "path": "services/security",
167 "kind": "rust-worker",
168 "worker": "g1t-security",
169 "d1": { "database": "g1t-security", "migrations": "migrations" },
170 "stage": "core",
171 "secrets": [],
172 "self_host": "run"
173 },
174 "deployments": {
175 "path": "services/deployments",
176 "kind": "ts-worker",
177 "worker": "g1t-deployments",
178 "d1": { "database": "g1t-deployments", "migrations": "migrations" },
179 "stage": "core",
180 "secrets": ["CLOUDFLARE_API_TOKEN"],
181 "setup": [
182 "Workers for Platforms, and the dispatch namespace: scripts/setup-deployments.sh",
183 "Custom domains (Cloudflare for SaaS on g1t.page): scripts/setup-custom-domains.sh"
184 ],
185 "self_host": "run"
186 },
187 "runner": {
188 "path": "services/runner",
189 "kind": "ts-worker",
190 "worker": "g1t-runner",
191 "stage": "core",
192 "secrets": ["AI_GATEWAY_TOKEN"],
193 "setup": [
194 "Containers on the account; Docker on the machine that builds a new image",
195 "The base image, once: node scripts/deploy.mjs build-base"
196 ],
197 "image": {
198 "dockerfile": "services/runner/Dockerfile",
199 // The binary the image adds to its base (scripts/build-runner.mjs).
200 "crate": "g1t-runner",
201 "base": { "context": "services/runner/base", "lock": "services/runner/base.json" },
202 "repository": "g1t-runner"
203 },
204 "self_host": "off"
205 },
206 "context": {
207 "path": "services/context",
208 "kind": "ts-worker",
209 "worker": "g1t-context",
210 "d1": { "database": "g1t-context", "migrations": "migrations" },
211 "stage": "core",
212 "secrets": [],
213 "setup": [
214 "The Vectorize index: npx wrangler vectorize create g1t-context --dimensions=768 --metric=cosine, with metadata indexes on workspace, kind, project and private"
215 ],
216 "self_host": "off"
217 },
218 "og": {
219 "path": "services/og",
220 "kind": "ts-worker",
221 "worker": "g1t-og",
222 "stage": "core",
223 "secrets": [],
224 "setup": ["Browser Rendering on the account (the BROWSER binding)"],
225 // The roadmap cards read the site's roadmap.
226 "inputs": ["apps/web/app/lib/roadmap.ts"],
227 "self_host": "none"
228 },
229 "api": {
230 "path": "apps/api",
231 "kind": "rust-worker",
232 "worker": "g1t-api",
233 "stage": "edge",
234 "secrets": [],
235 "self_host": "none"
236 },
237 "models": {
238 "path": "services/models",
239 "kind": "ts-worker",
240 "worker": "g1t-models",
241 "stage": "edge",
242 "secrets": ["AI_GATEWAY_TOKEN"],
243 "setup": ["The AI Gateway `g1t`"],
244 "self_host": "none"
245 },
246 "pages": {
247 "path": "services/pages",
248 "kind": "ts-worker",
249 "worker": "g1t-pages",
250 "stage": "edge",
251 "secrets": [],
252 "setup": ["A proxied wildcard DNS record on g1t.page (`*`, AAAA 100::): scripts/setup-deployments.sh"],
253 "self_host": "none"
254 },
255 "status": {
256 "path": "apps/status",
257 "kind": "ts-worker",
258 "worker": "g1t-status",
259 "d1": { "database": "g1t-status", "migrations": "migrations" },
260 "stage": "edge",
261 "secrets": ["STATUS_SECRET"],
262 "setup": ["Email Sending on g1t.sh (the EMAIL binding)"],
263 "self_host": "separate"
264 },
265 "web": {
266 "path": "apps/web",
267 "kind": "react-router",
268 "worker": "g1t",
269 "stage": "front",
270 "secrets": [],
271 "setup": ["The R2 bucket g1t-downloads, for the self-hosted runner's releases: npx wrangler r2 bucket create g1t-downloads"],
272 "self_host": "run"
273 },
274 "sudo": {
275 "path": "apps/sudo",
276 "kind": "react-router",
277 "worker": "g1t-sudo",
278 "stage": "front",
279 "secrets": [],
280 "setup": ["A Cloudflare Access application on sudo.g1t.sh; its AUD tag is ACCESS_AUD"],
281 "self_host": "none"
282 },
283 "docs": {
284 "path": "apps/docs",
285 "kind": "astro",
286 "worker": "g1t-docs",
287 "stage": "front",
288 "secrets": [],
289 "self_host": "none"
290 }
291 }
292}