Cloudflare Containers CI executor Draft

2026-10-11 · ForgeGraph · FORGE-68 (CI speed) · aligns with FORGE-67 (Forgejo removal, CI control plane)

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.yml split into parallel jobs, which is needed for any executor
  • CI job image (Node 24, pnpm, Go, git, gitleaks, PostgreSQL binaries)
  • CiRunnerContainer + CiExecutorPool Durable 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.

api + web unit suites
292 s
Typecheck
127 s
DB + concurrency suites
88 s
Go vet + test (mostly compile)
77 s
Leaf package tests
22 s

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

Control planeForgejo now; /api/actions (FORGE-67) later. Queues tasks by runs-on labels.
→
CiExecutorPool (DO)Alarm every ~10 s: pending cloudflare tasks minus warm containers gives how many to start, up to a cap.
→
CiRunnerContainerstandard-4 (4 vCPU / 12 GiB). Entrypoint: forgejo-runner one-job --wait, host mode.
→
RunnerServiceFetchTask → UpdateLog / UpdateTask → exit. The container sleeps, and billing stops.
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

DecisionChoiceWhy
Executor binaryStock forgejo-runner v13 one-jobThe protocol stays correct by construction, and there is no second implementation of task, log and step semantics.
Execution modeHost 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 containersNot supported on cloudflare; PostgreSQL baked in the image and started by a stepThe DB suites need postgres. A step runs pg_ctl start on localhost instead of services:.
CredentialsWorker serves the runner token through --token-urlNo token in the image. The token is scoped to the cloudflare label and rotates.
Scaling signalPending-task count per label, then later a push from the run Durable ObjectPolling the snapshot works today; a push avoids polling once FORGE-67 owns run state.
Dependency cachepnpm store baked into the image per lockfile hashNode-local actions caches aren't reachable from Cloudflare. A baked store makes the install mostly link-only.

Routing: which jobs move

JobTargetNotes
gitleaks, lint, workflow and script checkscloudflareLight, and gate fast.
api / web / other unit suitescloudflareShard further with vitest --shard once measured.
DB + concurrency suitescloudflarePostgreSQL runs as a process in the job image.
ci aggregator (required check)cloudflareMerges check-events and the failure log tail, then reports to ForgeGraph.
Typecheck, web-build, storybook buildnodes (heavy)CPU- and memory-bound builds; this is the node pool's job.
Go vet/test, deploys, releasesnodesWarm Go caches; deploys need host access.

Phases

TaskFilesVerificationStatus
1. Split ci into parallel jobs, with an aggregator still named ci.forgejo/workflows/ci.yml, .forgejo/actions/pnpm-installRequired checks unchanged; a failing sub-job fails CI / ci and reports a log tailIn progress
2. CI job image + manual one-job proof of concept against Forgejoops/ci-executor/DockerfileA cloudflare-labeled gitleaks job passes in a containerPlanned
3. CiExecutorPool Durable Object + CiRunnerContainer Workerapps/ci-executor/Pool scales 0 → N → 0 on queue depth; containers exit after one jobPlanned
4. Move light jobs to cloudflare; DB suites with in-image PostgreSQL.forgejo/workflows/ci.ymlPR critical path ≤ 6 min p50; no flake increase over 2 daysPlanned
5. Point the executor at /api/actions when FORGE-67 landsexecutor configThe same jobs pass against the new control planeBlocked 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)

  1. A per-label pending-task signal: a count endpoint, or a push to CiExecutorPool when a run Durable Object enqueues a task whose labels match cloudflare.
  2. 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.
  3. Cancellation delivered through UpdateTask, so a cancelled run stops its container promptly.
  4. Keep host-mode semantics: tasks routed to cloudflare must not declare services:, and the control plane should reject that combination early with a clear error.

Risks

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.