Repository navigation
build(deploy): build every cloud service through one turbo graph - #2425
Conversation
apps/cloud becomes the private workspace package @zitadel/cloud with three turbo tasks: `build` (the launcher, apps/cloud/dist/nextgen-launcher, via build-launcher.sh with build.sh's ldflags and -tags noconsole), `schemas` (apps/cloud/dist/cloud-schemas) and `dev` (pnpm run cloud's script, replacing the root //#cloud). Moon gets no cloud project. - build.sh builds the launcher with `turbo run build --filter=@zitadel/cloud`, copies it to $VERCEL_OUTPUT_FILE and migrates; the migration is never cached. The launcher's key holds VERCEL_GIT_COMMIT_REF, the branch it stamps in to pick a preview's database, and leaves out .vercel/** and node_modules: turbo hashes the ignored files a glob matches, and on Vercel the Go toolchain and module cache lie in .vercel/cache/golang. The Go cache prune moved into the build task, so a cache hit does not empty Go's cache. - The docs and website services run `turbo run build --filter=...`. Their builds now see the Speed Insights sample rates (strict mode hid them), and are keyed by VERCEL_DEPLOYMENT_ID: Skew Protection bakes the deployment's ID into a Next.js build, so they never hit on Vercel. The docs' generate and typecheck drop the inferred NEXT_DEPLOYMENT_ID and still hit. The docs' build script is plain `next build`, as moon's. - The schemas service runs `turbo run schemas --filter=@zitadel/cloud` with the shared install and stays rooted at apps/cloud, whose package.json has no dependencies, so Vercel still detects no framework. - Runbook, README, turbo design docs and AGENTS.md files follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 3cbd88e The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Revert wording the package does not need, so the change stays clear of the open PRs that edit the same files: the README's build.sh row (beside the row #2397 changes), two runbook phrasings, the root turbo.json header and the turborepo.md bullet on ignored files in input globs, which the rework of #2420 covers. The cloud task's own comment keeps why it excludes .vercel/ and the other ignored trees. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
apps/server/turbo.json and moon.yml lie under @zitadel/server's publishable root, so the changeset check wants a changeset; they only rename the file the launcher's tests read (build-launcher.sh), and nothing ships. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 299048754d
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
There was a problem hiding this comment.
🔵 Needs a closer look
This Vercel build/deploy change hinges on turbo remote-cache behavior, prune, and deployment keying that can only be validated through actual preview and deployment-check runs rather than static inspection.
No open issues 🎉
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
This PR moves the hosted cloud's Vercel builds onto a single turbo task graph so CI and deployments share the same tasks and the team's remote cache. apps/cloud becomes the private @zitadel/cloud package (no moon project) with build (launcher), schemas, and dev tasks. The server service's build.sh now delegates compilation to turbo (build-launcher.sh) and only copies the binary and runs migrations; docs/website/schemas services build through turbo filters. Extensive docs are updated to match, plus an empty changeset for the apps/server build-config touch that ships nothing.
Changes:
- Introduce
@zitadel/cloudpackage +apps/cloud/turbo.json; split Go compilation intobuild-launcher.sh, leavingbuild.shto run turbo + migrate. - Point
vercel.jsonservices (docs, website, schemas) at turbo filters; move schemas output underapps/cloud/dist/cloud-schemas; addVERCEL_DEPLOYMENT_ID/Speed-Insights env to Next.js build tasks and dropNEXT_DEPLOYMENT_IDfrom docsgenerate/typecheck. - Update runbook/design/AGENTS docs and the launcher test to reference
build-launcher.sh.
| File | Description |
|---|---|
vercel.json |
Docs/website/schemas services now build via turbo filters; schemas install enabled, output dir rerooted to apps/cloud. |
turbo.json |
Removes root //#cloud dev task (replaced by @zitadel/cloud#dev). |
apps/cloud/turbo.json |
New build/schemas/dev tasks with Go-input globs, Vercel ignore excludes, and deployment-keying env. |
apps/cloud/package.json |
New private @zitadel/cloud package (AGPL-3.0-only) with build/schemas/dev scripts. |
apps/cloud/build.sh |
Delegates compile to turbo, installs when needed, copies binary to $VERCEL_OUTPUT_FILE, then migrates. |
apps/cloud/build-launcher.sh |
New launcher compile (ldflags, -tags noconsole) + Go cache prune guarded by VERCEL. |
apps/cloud/launcher/main_test.go |
Test reads build-launcher.sh. |
apps/cloud/launcher/database.go, internal/staticui/console/embed_noconsole.go |
Comment references updated to build-launcher.sh. |
apps/docs/package.json |
build script reduced to next build (bundling via turbo generate). |
apps/docs/turbo.json, apps/website/turbo.json |
Add deployment-ID/Speed-Insights env; docs drops NEXT_DEPLOYMENT_ID from generate/typecheck. |
apps/server/turbo.json, apps/server/moon.yml |
Rename test input build.sh → build-launcher.sh. |
scripts/render-builtin-schemas.mjs |
DEFAULT_OUT_DIR moved to apps/cloud/dist/cloud-schemas; comments updated. |
scripts/run-cloud.mjs |
Comment updates only. |
pnpm-lock.yaml |
Registers empty apps/cloud workspace importer. |
.changeset/cloud-turbo-package.md |
Empty changeset (publishable path touched, nothing ships). |
docs/runbooks/cloud.md, docs/design/build/turborepo.md, docs/design/build/turborepo-migration.md, apps/AGENTS.md, apps/docs/AGENTS.md, apps/website/AGENTS.md, .moon/AGENTS.md, apps/cloud/README.md |
Documentation updated to reflect the unified turbo build graph. |
Review effort: Balanced
…o task The server service's build command now installs (the Go preset runs no installCommand) and runs `turbo run deploy --filter=@zitadel/cloud`. @zitadel/cloud's new `deploy` task depends on `build` (the launcher, from the cache when nothing it compiles changed) and runs deploy.sh, the former build.sh without its install and turbo call: copy the binary to $VERCEL_OUTPUT_FILE, then migrate. It is never cached, and it passes the whole environment through (`passThroughEnv: ["*"]`): the launcher checks every variable the function needs at build time, so a variable strict mode hid (CRON_SECRET, which #2397 adds, or any later one) would fail every deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…asks Split the uncached `deploy` task in two, ordered with dependsOn: `migrate` (after `build`; the launcher's migration, with the whole environment passed through) and `deploy` (after `migrate`; deploy.sh now only copies the binary to $VERCEL_OUTPUT_FILE, and only once the migration applied). The server's build command still installs first: Vercel's Go builder runs no installCommand, and turbo comes with the install. The docs' generate and typecheck drop every NEXT_* variable from their keys, not only NEXT_DEPLOYMENT_ID: the docs service's builds also hash Vercel's NEXT_PUBLIC_VERCEL_* variables, and the second preview missed both tasks with their inputs unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The launcher runs with the deployment's secrets (`migrate`) and becomes its function, and branch builds (previews, CI over OIDC) can write the team's remote cache, whose keys leave out PATH: an entry planted under production's key would have run in production. @zitadel/cloud#build is now uncached; Go's own build cache, which Vercel keeps per branch, keeps the compile short. Its inputs still decide when it is affected, and GOFLAGS, GOOS and GOARCH (which Vercel's Go builder sets for the function's architecture) pass through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cripts The docs' `dev` script bundled the API reference and the CLI reference before `next dev`, the `generate` task's work, which both graphs already run first (moon's docs:dev runs `next dev` itself). It is plain `next dev` now, as the `build` script became `next build`. turborepo.md states the rule: a script does its own task's work only, and a step that is a task of its own is a dependsOn edge and a moon dep, never `a && b`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vercel's Go builder runs no installCommand and runs the build command through build-utils' execCommand with the container's PATH and Go's, while the JS builders (@vercel/next, @vercel/static-build) put every node_modules/.bin up to the repo root on PATH first. So the server's build command installs itself and calls node_modules/.bin/turbo; vercel.json takes no comments, so the runbook's layout row says it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zitadel/cloud#dev listed CLOUD_DEV_*, NEXTGEN_* and GOFLAGS (the old //#cloud's list), so under turbo the local cloud's server never saw the OpenTelemetry SDK's OTEL_* variables, or anything else a service reads. `vercel dev` hands the environment to every service, as `pnpm run cloud` does, and the task is uncached, so it passes everything through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the conflict in docs/runbooks/cloud.md's service table: main now builds every cloud service through one turbo graph (#2425), and this branch adds /api/* to what the server serves. The server row takes main's build and this branch's paths. The generated code matches a fresh server:generate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Why: this is about turbo's build logic, which the hosted cloud's Vercel builds use and which may replace moon one day.
Puts the hosted cloud's Vercel builds on turbo's task graph, so CI and the deployments run the same tasks against the team's remote cache. Moon stays the required gate and gets no cloud project.
apps/cloudis a package,@zitadel/cloud(private), with five tasks inapps/cloud/turbo.json:build: the launcher,apps/cloud/dist/nextgen-launcher, compiled by the newbuild-launcher.sh(build.sh'sgo buildwith the same ldflags and-tags noconsole). Never cached: the launcher runs with the deployment's secrets and becomes its function. Branch builds (previews, CI over OIDC) can write the team's remote cache, so an entry planted under production's key would run in production; Codex's security review caught this. Go's own build cache, which Vercel keeps per branch, keeps the compile short. Its inputs (the Go files and what they embed, as moon'sserverInputslists them, plus the server's version) still decide when it is affected.migrate: never cached, depends onbuild, and runslauncher migrate. It passes the whole environment through (passThroughEnv: ["*"]). The launcher checks every variable the function needs at build time, and strict mode would hide any variable nobody listed, such as feat: let a scheduler start the audit event purge instead of the server's timer #2397'sCRON_SECRET.deploy: never cached, depends onmigrate.deploy.shcopies the binary to$VERCEL_OUTPUT_FILE, a temp path outside the repository where Vercel's Go builder takes the function from. A failed migration stops the run before the copy.schemas:apps/cloud/dist/cloud-schemas, rendered byscripts/render-builtin-schemas.mjs, whose default output moved there.dev:pnpm run cloud's script, which replaces the root//#cloud. It passes the whole environment through, aspnpm run clouddoes:vercel devhands it to every service, and the server alone readsNEXTGEN_*andOTEL_*.serverservice's build command ispnpm install … && node_modules/.bin/turbo run deploy --filter=@zitadel/cloud. Vercel's Go builder never runs aninstallCommand: its source has none, and the "Running install" step lives in the JS builders. So the install has to precede turbo in the command; turbo itself comes with it. pnpm skips the install in milliseconds once an earlier service installed. The Go build-cache prune moved into the build task: after a turbo hit Go has refreshed nothing, and the prune would empty its cache.turbo run build --filter=@zitadel/docs/--filter=@zitadel/website. Their builds now listDOCS_SPEED_INSIGHTS_SAMPLE_RATE/WEBSITE_SPEED_INSIGHTS_SAMPLE_RATE: both are read at build time, and strict mode would have hidden them, sending Speed Insights for every page load. The docs'buildanddevscripts are plainnext buildandnext dev, as moon's commands; theirgeneratedependency bundles first.turborepo.mdnow states the rule: a script does its own task's work only, and a step that is a task of its own goes through the graph, nevera && b.turbo run schemas --filter=@zitadel/cloudwith the shared install. It stays rooted atapps/cloud. A service takes noframework: null, and Vercel detects frameworks from dependencies, which thispackage.jsonhas none of. So it still builds as a static service.apps/cloud/README.md, the cloud runbook,docs/design/build/turborepo.md(it said the docs and website bypass turbo, and thatbuild.shbuilds a login UI), the migration plan,.moon/AGENTS.md, and the apps'AGENTS.mdfiles.Two traps this avoids
.vercel/cache/golang. The launcher's$TURBO_ROOT$/**/*.gowould hash the Go standard library and every module in the cache, and the key would follow the cache's contents. The task excludes.vercel/**,node_modulesand agents' worktrees (.claude/, …), the same list as build: stop docs and test edits from re-running the task graph, and let turbo select what ci-turbo runs #2420.skewProtectionMaxAge43200). A Next.js build bakes the deployment's ID into every asset URL (?dpl=), and Vercel's URLs into its metadata, which turbo passes through unhashed. Turbo already hashesNEXT_DEPLOYMENT_IDinto every task of a Next.js package. The builds also listVERCEL_DEPLOYMENT_ID, so the key holds the deployment even if Skew Protection goes off. The docs'generateandtypecheckread noNEXT_*variable, so they drop them all (!NEXT_*) and still hit. Dropping onlyNEXT_DEPLOYMENT_IDwasn't enough: the docs service's builds also hash Vercel'sNEXT_PUBLIC_VERCEL_*variables (URL, commit), and the second preview missed both tasks with unchanged inputs.So on Vercel the docs and website gain one graph and a strict environment, not speed. Each deployment uploads a docs build (about 31 MB compressed, measured locally) and a website build (about 2.5 MB) that no other deployment can use. The docs service also runs the docs typecheck now:
builddepends on it, as in moon. That costs time only when the docs change, since a cached typecheck is restored. Real reuse would take turning Skew Protection off, which is a product decision.Validation
turbo run build schemas --filter=@zitadel/cloudtwice:schemasis a cache hit on the rerun, andbuildruns both times (uncached by design, see above).go version -mon the binary shows-tags=noconsole,CGO_ENABLED=0,-trimpath..vercel/cache/golangdon't change the launcher's hash, and no input comes fromnode_modules.VERCEL_TARGET_ENVchanges every key, which is why CI's entries are never hits on Vercel (the migration plan said they were; corrected).vercel.json, run locally with an install-only stubpnpm:VERCEL_OUTPUT_FILEset:build(cache hit), thenmigrate(applied, scratch SQLite), thendeploy(copied the binary).CLOUD_*database URLs pointed at one host on purpose:migratefailed on the pooler check, which names both variables, so they reached it through turbo.deploynever ran, and nothing was copied.turbo run deploy --filter=@zitadel/cloudlocally without Vercel: migrates, thendeploysays there is nothing to hand over.NEXT_DEPLOYMENT_ID,VERCEL_DEPLOYMENT_IDandNEXT_PUBLIC_VERCEL_*: the docs'generateandtypecheckkeep one key, and the build gets one per deployment.NEXT_DEPLOYMENT_ID/VERCEL_DEPLOYMENT_ID). The first: 12 misses, 31 s. The second: 10 hits, including the docs'generateandtypecheck; only the two Next.js builds re-ran (10 s), and the website's HTML carries the second deployment'sdpl=.go test ./apps/cloud/launcher/ -count=1;vitest run scripts/render-builtin-schemas.test.mjsmoon run workspace:check-moon-graph; Biome on the changed scripts;node scripts/check-pr-title.mjsturbo boundaries: 40 issues on this branch, the same as onmain(thevitest.shared.mjsimports build: run turbo boundaries in CI and move the shared Vitest config into a package #2423 fixes), none in@zitadel/cloud. With build: run turbo boundaries in CI and move the shared Vitest config into a package #2423 merged in: no issues, 39 packages.deployment-checks: see the checks on this PR.Release notes / changeset
Empty changeset (
.changeset/cloud-turbo-package.md):apps/server/turbo.jsonandapps/server/moon.ymllie under@zitadel/server's publishable root, but they only rename the file the launcher's tests read. Nothing ships.Notes
apps/cloud/build.shin@zitadel/server#test-postgresand#test-sqlite, and in an exception for#test-spannerinscripts/check-turbo-graph.mjs. The launcher's test now readsapps/cloud/build-launcher.sh, so whichever lands second renames those three. With all three PRs merged,check-turbo-graphreports exactly those. This PR leavesturborepo.md's inputs section and the rootturbo.jsonto build: stop docs and test edits from re-running the task graph, and let turbo select what ci-turbo runs #2420's rework, apart from dropping//#cloudandbuild.shfrom its header comment; that rework's rule on ignored files in input globs should name.vercel/for a task that runs on Vercel.vercel.json, the launcher, its test, the cloud README and the runbook too. Its one conflict with this branch is in the README's file table: feat: let a scheduler start the audit event purge instead of the server's timer #2397 changes thelauncher/row, and this PR replaces thebuild.shrow below it withdeploy.sh. Keep both. With both merged,deploypasses feat: let a scheduler start the audit event purge instead of the server's timer #2397'sCRON_SECRETthrough, which its build-time check needs.turborepo.md's command table, regardless of this PR.internal/errorpage/*andpackages/design-tokens/src/generated/tokens.css, both compiled in, which moon'sserverInputshas. The launcher's list here includes them.maindeploys production.🤖 Generated with Claude Code