Skip to content

Document server builds - #456

Draft
tnkuehne wants to merge 3 commits into
mainfrom
server-builds-docs
Draft

tnkuehne wants to merge 3 commits into
mainfrom
server-builds-docs

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Documents server builds (POST/GET /apps/{appId}/builds) from #455.

Publication is blocked on #455 and a release that includes it, and on the app CI being deployed on Widefleet Cloud.

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.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 4b3d5a3 Nov 27 2026, 11:06 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.
Base automatically changed from server-builds to main November 28, 2026 13:38
tnkuehne added a commit that referenced this pull request Nov 28, 2026
## 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 runs
`pnpm install --frozen-lockfile` (skipped without `package.json`, as in
`deploy`). It then runs `widefleet 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, because
`deploy` would 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.org`
- reads of the app's repository: clone, fetch, and the ref check of the
source push. Each request gets a fresh repository token from the control
plane, through the write-credential route that `deploy` uses. Pushes are
refused.
- the control plane calls of `widefleet deploy` for the build's app.
These are source target, source prepare, upload session, asset uploads,
publish, and the network state that `deploy` reports.

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}/builds` builds the branch's latest commit. It uses
the project directory of the active deployment, or `directory`. The
caller needs the same app rights as for deploying.
- `GET /apps/{appId}/builds` and `GET /apps/{appId}/builds/{buildId}`
report builds. The detail includes the end of the install and deploy
output.
- A `BuildWorkflow` runs 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:
- is valid while the build runs, until the build's deadline 30 minutes
after it was started;
- acts with the starter's recorded sign-in, so company SSO requirements
apply as they did when the build was started;
- has the scopes of the credential that started the build, so it reads
only if that credential could;
- works only on the routes `widefleet deploy` uses, 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
deploy` refuses, 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 in
`packages/app-ci/dist/cli`, and restores its execute bits: run `pnpm
--filter @platform/app-ci build --binary <widefleet built for Debian
bookworm>`, for example with the binary from
`tools/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 format
- `pnpm exec vitest run` in the control plane: all tests pass, including
`builds.integration.test.ts`. Its cases:
  - deploy with the build token and source metadata
  - the token stops working after the build and at its deadline
  - a token works only for the build it names
  - the token is confined to its app, also against input overrides
  - publish once after an interrupted run, keeping the recorded log
  - failed builds with their log
  - builds that do not publish
  - no network changes through builds
  - apps without saved source
- Earlier runs: the CI image (Node 26, pnpm 12.4.2, Git, the CLI from
the release toolchain) and `wrangler deploy --dry-run` of the control
plane and the app CI.
- **Not verified yet:** outbound interception in a deployed container.
Locally, `wrangler dev` cannot bind the egress listener with rootless
Docker, so this is checked on the first deployment.

Documentation: #456 (draft until a release includes this).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant