Repository navigation
Build app commits from Widefleet Git on the server - #455
Merged
Merged
Conversation
A server build runs the app's locked install and the new
`widefleet build --output` in a container of the app CI, then publishes
the output through the same upload path as `widefleet deploy`, with the
built commit as the deployment's source.
- `widefleet build --output DIR` builds as `deploy` does and writes the
deployment to a directory; `deploy` uses the same build.
- packages/app-ci: a Worker with a Durable Object container per build. Only
the npm registry and the app's repository are reachable; the repository
credential stays in the Worker.
- POST/GET /apps/{appId}/builds start and report builds; a Workflow runs
each build and publishes it under the account that started it.
- Hosted installations deploy the app CI and bind it to the control plane.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | ffb58c4 | Nov 28 2026, 01:26 PM |
The app CI no longer needs a build command of its own: the container clones the commit, installs the locked dependencies and runs widefleet deploy for the app. Credentials stay in the CI Worker. Its egress gateway passes only the npm registry, reads of the app's repository with a fresh token for each request, and the deploy calls of the build's app, to which it adds a build token that acts for whoever started the build while the build runs. The gateway sets the build ID as the idempotency key, so a build publishes at most once.
Build tokens work only through the API's app routes and only for the build's app, also when input fields name another app. They act with the starter's recorded sign-in and expire with the workflow run. The CI stops the container at the build deadline and on errors, skips the install without package.json, refuses installs that change files of the repository, runs widefleet deploy without waiting for the rollout and keeps outcomes at most a day. Workflow setup failures and apps without a repository finish their builds.
Build tokens now work only on the routes widefleet deploy uses: source target, source prepare, upload session and uploads, and the network state. The build is recorded together with its workflow; a run that starts before the commit is retried. A repeated run reports the CI's recorded outcome and log. Overlapping calls for one build share its run, the container is stopped also when its setup fails, command output is kept as a bounded tail while it streams, NUL is removed from stored logs, and the cleanup alarm is retried until it succeeds.
The CI's Git credential request was rejected since build tokens are limited to the deploy routes; the write-credential route that widefleet deploy uses is now one of them, and the CI uses it for every Git request. A build reads only when the credential that started it could. A repeated call joins a build that is still running and hands it the new token; a retry after publishing waits for its outcome. Failure recording waits for the build's commit, and builds whose workflow ended report that they failed.
A repeated run keeps the previous token valid, so requests of the run it joins are not refused. Reading a build whose workflow ended records its failure and ends its tokens, unless the build finished meanwhile. A build that published another commit than it was asked to build fails, a build whose CI restarted says that its log was lost, and the CI intercepts a control plane on another HTTPS port than 443.
A build's token names its build and is sealed with the installation's keyring instead of being stored, so every run of a build gets a valid token and a repeated run no longer ends the one a running container uses. Tokens and runs end at the deadline set when the build starts. The CI keeps a released build's outcome without its log, so a run that arrives after the release returns it instead of building again.
…es in database time A release during intercept registration no longer lets the run start its container or removes the deadline alarm it still needs. Build deadlines are set and checked with the database clock. The image restores the execute bits of the CLI and esbuild, which build artifacts can lose.
tnkuehne
force-pushed
the
server-builds
branch
from
November 28, 2026 12:56
2226f5b to
6265f4c
Compare
…ore looking up its repository Cloudflare advises Workflow step timeouts of at most 30 minutes. A build stops at its deadline, which starts before its step, so the step needs no longer. A repeated run of a build that already published now concludes it before it looks up the repository, which may be gone by then.
tnkuehne
added a commit
that referenced
this pull request
Nov 28, 2026
…459) ## What Server builds (#455) cost container time. With this change an installation can decide who builds and for how long. - **Build policy:** a runtime extension can provide `buildPolicy` (`runtime-extension.ts`). - `admit` runs in the transaction that records a build. It returns the seconds of container time the build may use, or why it cannot start, for example because the organization has no build time. - `settle` runs in the transaction that finishes the build, with the container time the CI reported. It runs only then, so each build settles at most once. - A build that ends without that report keeps its whole reservation. This happens when its workflow stopped, the setup failed, or the CI lost the run. Its container may still run until its deadline. The policy can keep the slot and the charge until then. - `@platform/control-plane/builds` exports `ciBuildTimeLimit`, the most a policy can grant. - **Time limit:** a build's deadline is its admission plus the seconds the policy granted, at most 30 minutes. It counts from the transaction that admits the build, as the policy's reservation does. - No run of the build goes past the deadline, so a build that waited past it in the queue runs no container at all. - An alarm in the Durable Object stops the container at the deadline, even if the object restarts in between. - A run that the object lost counts until it restarted, at most until the deadline. - The CI reports the container time it used (`seconds`). - **Without a policy:** every build may use the CI's longest build time. Self-hosted installations pay for their own Cloudflare account. ## Checks - `pnpm lint`, typecheck, format - `pnpm exec vitest run` in the control plane: all tests pass, including new `builds.integration.test.ts` cases: - a build the policy refuses is not recorded and gets no workflow - granted time reaches the CI, and the used time is settled once - builds that end without the CI's time keep their reservation - the CI receives the deadline of the granted time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Apps whose source is in Widefleet Git can be built and deployed by the server, without a local build. This is the base for clients that have no shell, such as chat assistants.
packages/app-ci: a Worker with one Durable Object container per build. The container clones the commit onto the app's branch and runspnpm install --frozen-lockfile(skipped withoutpackage.json, as indeploy). It then runswidefleet deploy --no-wait <app>, the same command as on a computer. An install that changes files of the repository fails the build, and the log lists the files, becausedeploywould commit them and builds cannot push. At the build's deadline, and on any error, the container is stopped. A build released while its container starts does not start it. A released build keeps its outcome without the log, so a late run of the same build returns that outcome instead of building again. A log nobody released is dropped after a day.Credentials stay in the CI Worker. The container has no Internet access. All HTTP and HTTPS goes through an outbound entrypoint, which allows only:
registry.npmjs.orgdeployuses. Pushes are refused.widefleet deployfor the build's app. These are source target, source prepare, upload session, asset uploads, publish, and the network state thatdeployreports.The entrypoint adds the build's token to these calls. It also sets the build ID as the idempotency key, so a build publishes at most once. Everything else is answered with 403.
Control plane:
POST /apps/{appId}/buildsbuilds the branch's latest commit. It uses the project directory of the active deployment, ordirectory. The caller needs the same app rights as for deploying.GET /apps/{appId}/buildsandGET /apps/{appId}/builds/{buildId}report builds. The detail includes the end of the install and deploy output.A
BuildWorkflowruns each build. Each run gets a build token (wfb_<build ID>.…) that names its build and is sealed with the installation's keyring, so it is not stored. The token:widefleet deployuses, and only for the build's app. This holds even when input fields name another app, which the API's input decoding allows.Build tokens cannot start builds, list apps, or manage network access. Origins that a new version requests stay requested, as with every deploy.
A repeated call joins a build that is still running; the tokens of all its runs stay valid. A retry after publishing waits for the CI's outcome. No run of a build goes past its deadline.
Setup failures of the workflow, and apps without a repository, finish their builds as failed. A build whose workflow ended without finishing it is reported as failed, as in deployment history.
If the branch moved on before the build saved its source,
widefleet deployrefuses, as it does locally, and the build fails.Hosted installations deploy the app CI next to the app builders and bind it as
APP_CI. The image needs the CLI inpackages/app-ci/dist/cli, and restores its execute bits: runpnpm --filter @platform/app-ci build --binary <widefleet built for Debian bookworm>, for example with the binary fromtools/build-release-binaries.sh.Installations without an app CI report that they do not build apps on the server. Nothing changes for them.
Checks
pnpm lint, typecheck, and formatpnpm exec vitest runin the control plane: all tests pass, includingbuilds.integration.test.ts. Its cases:wrangler deploy --dry-runof the control plane and the app CI.wrangler devcannot bind the egress listener with rootless Docker, so this is checked on the first deployment.Documentation: #456 (draft until a release includes this).