Cloudflare Containers CI executor Draft
Recommendation: run light CI jobs on Cloudflare Containers through an executor, not a new control plane. Each container runs the stock forgejo-runner one-job in host mode with a cloudflare label, claims exactly one task over the RunnerService protocol, streams logs, and exits. Because it speaks the protocol the self-hosted fleet already speaks, it works against Forgejo today and against FORGE-67's /api/actions later by changing one URL. CPU-heavy work (typecheck, production builds, Go, deploys) stays on the node pool.
This plan (FORGE-68)
- The
ci.ymlsplit into parallel jobs, which is needed for any executor - CI job image (Node 24, pnpm, Go, git, gitleaks, PostgreSQL binaries)
CiRunnerContainer+CiExecutorPoolDurable Object (autoscaling)- Label routing: which jobs move to
cloudflare
FORGE-67 owns
- Git gateway on Cloudflare Artifacts; PRs, merge and push events
- RunnerService at
/api/actions; per-run Durable Object state; logs in R2 - Runner registration, task assignment, cancellation
- Migration off Forgejo; D1 / ForgeC
Why: where PR CI time goes today
These are measured values: median duration over 2 days of ForgeGraph runs, from Forgejo's task tables. The single ci job runs every suite in sequence (12.2 min median, 19.7 max) after a median 8.3 min queue wait.
The suites are independent, so running them as parallel jobs puts the critical path at about the longest single suite plus setup. That is an estimate of ~5 min instead of ~12, and it only holds if there are enough runner slots. That second condition is the case for Containers: the default account limit is 1,500 concurrent vCPU.
Deploys are limited by the host, not the pipeline definition. The production deploy job runs on a 4-vCPU / 7 GB host that also serves git hosting, the control-plane database and observability. During one deploy on 2026-10-11 its load average was 30–39, and Build and deploy took 1,024 s against a 528 s median. That pushed the job past its 25-minute timeout during the optional secret-sync step at the end. Moving git hosting off that host (FORGE-67) and building the Worker bundle on the node pool or in a container, uploading only from the deploy lane, both relieve this.
Architecture
/api/actions (FORGE-67) later. Queues tasks by runs-on labels.cloudflare tasks minus warm containers gives how many to start, up to a cap.forgejo-runner one-job --wait, host mode.forgejo-runner one-job --wait \ --url "$CONTROL_PLANE_URL" # Forgejo today, /api/actions later --token-url "$POOL_WORKER/runner-token" \ --label cloudflare:host \ [--handle "$TASK_HANDLE"] # Forgejo >= 15: assign a specific task
Design decisions
| Decision | Choice | Why |
|---|---|---|
| Executor binary | Stock forgejo-runner v13 one-job | The protocol stays correct by construction, and there is no second implementation of task, log and step semantics. |
| Execution mode | Host mode (cloudflare:host) | Docker-in-container needs root dockerd with --iptables=false and host networking. act's per-job service networks don't work there. |
| Service containers | Not supported on cloudflare; PostgreSQL baked in the image and started by a step | The DB suites need postgres. A step runs pg_ctl start on localhost instead of services:. |
| Credentials | Worker serves the runner token through --token-url | No token in the image. The token is scoped to the cloudflare label and rotates. |
| Scaling signal | Pending-task count per label, then later a push from the run Durable Object | Polling the snapshot works today; a push avoids polling once FORGE-67 owns run state. |
| Dependency cache | pnpm store baked into the image per lockfile hash | Node-local actions caches aren't reachable from Cloudflare. A baked store makes the install mostly link-only. |
Routing: which jobs move
| Job | Target | Notes |
|---|---|---|
| gitleaks, lint, workflow and script checks | cloudflare | Light, and gate fast. |
| api / web / other unit suites | cloudflare | Shard further with vitest --shard once measured. |
| DB + concurrency suites | cloudflare | PostgreSQL runs as a process in the job image. |
ci aggregator (required check) | cloudflare | Merges check-events and the failure log tail, then reports to ForgeGraph. |
| Typecheck, web-build, storybook build | nodes (heavy) | CPU- and memory-bound builds; this is the node pool's job. |
| Go vet/test, deploys, releases | nodes | Warm Go caches; deploys need host access. |
Phases
| Task | Files | Verification | Status |
|---|---|---|---|
1. Split ci into parallel jobs, with an aggregator still named ci | .forgejo/workflows/ci.yml, .forgejo/actions/pnpm-install | Required checks unchanged; a failing sub-job fails CI / ci and reports a log tail | In progress |
| 2. CI job image + manual one-job proof of concept against Forgejo | ops/ci-executor/Dockerfile | A cloudflare-labeled gitleaks job passes in a container | Planned |
| 3. CiExecutorPool Durable Object + CiRunnerContainer Worker | apps/ci-executor/ | Pool scales 0 → N → 0 on queue depth; containers exit after one job | Planned |
4. Move light jobs to cloudflare; DB suites with in-image PostgreSQL | .forgejo/workflows/ci.yml | PR critical path ≤ 6 min p50; no flake increase over 2 days | Planned |
5. Point the executor at /api/actions when FORGE-67 lands | executor config | The same jobs pass against the new control plane | Blocked on FORGE-67 |
Cost (estimate, not measured)
From the published Containers pricing: $0.000020 per active vCPU-second and $0.0000025 per GiB-second of allocated memory, after included usage. A 3-minute job on standard-4 using 4 vCPU comes to about $0.014 of CPU plus $0.005 of memory, roughly $0.02 per job, or about $0.10–0.15 per PR run of 5–7 jobs. Containers sleep to zero between jobs. Actual CPU usage per job is not yet measured.
Requests to FORGE-67 (control plane)
- A per-label pending-task signal: a count endpoint, or a push to
CiExecutorPoolwhen a run Durable Object enqueues a task whose labels matchcloudflare. - Runner token issuance for a label-scoped pool identity, plus support for
one-job --handle, so the pool assigns a specific task instead of containers racing on FetchTask. - Cancellation delivered through UpdateTask, so a cancelled run stops its container promptly.
- Keep host-mode semantics: tasks routed to
cloudflaremust not declareservices:, and the control plane should reject that combination early with a clear error.
Risks
- Host mode skips job isolation inside the container. Mitigation: one job per container, then exit. The microVM is the isolation boundary.
- Cold start and image pull time. Mitigation: keep a small warm pool sized by the time-of-day queue; measure cold start in phase 2.
- Network reach. Containers can't reach the tailnet. Jobs may only depend on public endpoints: git, npm registries, the ForgeGraph API.
- Image drift from the node image. Mitigation: build both images from one Dockerfile base and pin Node, pnpm and Go versions to the repository.
Method and sources
Step timings come from Forgejo's action_task_step and action_run_job tables for the ForgeGraph repository, last 2 days, successful tasks only. Container limits and pricing come from the Cloudflare Containers documentation (limits and pricing pages, read 2026-10-11). The runner capabilities (one-job, --handle, --token-url, --ephemeral) were read from forgejo-runner v13.0.0 --help on a fleet runner.