FORGE-79: Cloudflare Containers CI executor (proof of concept) #686

Merged
gmackie merged 1 commit from FORGE-79-cf-executor-poc into main 2026-10-12 03:50:32 +00:00
Owner

Issue: https://tasks.gmac.io/gmacko/issue/FORGE-79 · plan: https://xev2v724is67.postplan.dev (phase 2) · aligned with FORGE-67 (executor only; it owns the control plane)

What

  • apps/ci-executor: a Worker with a CiRunnerContainer (@cloudflare/containers 0.3.7, standard-4, max 4 instances). Each container runs forgejo-runner one-job --wait --label cloudflare:host, claims exactly one task, and exits. POST /run?count=N (bearer EXECUTOR_ADMIN_TOKEN) starts containers by hand for now; autoscaling is phase 3.
  • Image (container/Dockerfile): Node 24.14, pnpm 10.19, PostgreSQL 17 (PGDG), gitleaks 8.30.1, git, and forgejo-runner 13.0.0 pinned by sha256. No credentials are baked in. entrypoint.sh writes RUNNER_TOKEN to a 0600 file for --token-url and unsets it before exec, so job steps don't inherit it.
  • cf-executor-smoke.yml: runs-on: cloudflare, on PRs touching the executor. It runs checkout, toolchain versions, the same gitleaks scan as ci.yml, and PostgreSQL started as a process (host mode has no service containers). It is not a required check.

Already in place (outside this diff)

  • Forgejo runner #28 cf-containers, registered with a shared secret, scoped to gmackie/ForgeGraph (the CLI ignored --scope, so repo_id was set on that row directly), label cloudflare. No job on the instance had ever requested that label.
  • Worker deployed at forgegraph-ci-executor.gmac.workers.dev. Secrets RUNNER_TOKEN and EXECUTOR_ADMIN_TOKEN are set, preview URLs are off, /health returns 200, and /run without a token returns 401.
  • Image pushed as registry.cloudflare.com/<account>/forgegraph-ci-executor:poc1. wrangler's own build passes --provenance, which podman rejects, so the config references the pushed image.

Verification so far

  • one-job with a file:// token authenticated as runner #28, declared cloudflare, and exited on "no task received" (run on hetzner-ci, no task).
  • Image entrypoint run locally (amd64 under emulation): authenticated, polled, and stopped at the deadline (exit 124). RUNNER_TOKEN absent from the environment.
  • apps/ci-executor tsc --noEmit is clean, and the workflows parse (10 files).
  • Pending: this PR queues the smoke job; I'll start a container with /run and confirm it claims and passes the job on Cloudflare.

Known limits (phase 3+)

Host mode shares the container with the job, so a job step could read the runner token file. That token is repo-scoped, and each container runs one job, but per-task tokens or --handle assignment (asked of FORGE-67) would remove this exposure. Pool autoscaling and moving real ci.yml jobs are later phases.

🤖 Generated with Claude Code

Issue: https://tasks.gmac.io/gmacko/issue/FORGE-79 · plan: https://xev2v724is67.postplan.dev (phase 2) · aligned with FORGE-67 (executor only; it owns the control plane) ## What - **`apps/ci-executor`**: a Worker with a `CiRunnerContainer` (`@cloudflare/containers` 0.3.7, `standard-4`, max 4 instances). Each container runs `forgejo-runner one-job --wait --label cloudflare:host`, claims exactly one task, and exits. `POST /run?count=N` (bearer `EXECUTOR_ADMIN_TOKEN`) starts containers by hand for now; autoscaling is phase 3. - **Image** (`container/Dockerfile`): Node 24.14, pnpm 10.19, PostgreSQL 17 (PGDG), gitleaks 8.30.1, git, and forgejo-runner 13.0.0 pinned by sha256. No credentials are baked in. `entrypoint.sh` writes `RUNNER_TOKEN` to a 0600 file for `--token-url` and unsets it before exec, so job steps don't inherit it. - **`cf-executor-smoke.yml`**: `runs-on: cloudflare`, on PRs touching the executor. It runs checkout, toolchain versions, the same gitleaks scan as `ci.yml`, and PostgreSQL started as a process (host mode has no service containers). It is **not** a required check. ## Already in place (outside this diff) - Forgejo runner **#28 `cf-containers`**, registered with a shared secret, scoped to **gmackie/ForgeGraph** (the CLI ignored `--scope`, so repo_id was set on that row directly), label `cloudflare`. No job on the instance had ever requested that label. - Worker deployed at `forgegraph-ci-executor.gmac.workers.dev`. Secrets `RUNNER_TOKEN` and `EXECUTOR_ADMIN_TOKEN` are set, preview URLs are off, `/health` returns 200, and `/run` without a token returns 401. - Image pushed as `registry.cloudflare.com/<account>/forgegraph-ci-executor:poc1`. wrangler's own build passes `--provenance`, which podman rejects, so the config references the pushed image. ## Verification so far - `one-job` with a `file://` token authenticated as runner #28, declared `cloudflare`, and exited on "no task received" (run on hetzner-ci, no task). - Image entrypoint run locally (amd64 under emulation): authenticated, polled, and stopped at the deadline (exit 124). `RUNNER_TOKEN` absent from the environment. - `apps/ci-executor` `tsc --noEmit` is clean, and the workflows parse (10 files). - **Pending:** this PR queues the smoke job; I'll start a container with `/run` and confirm it claims and passes the job on Cloudflare. ## Known limits (phase 3+) Host mode shares the container with the job, so a job step could read the runner token file. That token is repo-scoped, and each container runs one job, but per-task tokens or `--handle` assignment (asked of FORGE-67) would remove this exposure. Pool autoscaling and moving real `ci.yml` jobs are later phases. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(ci): Cloudflare Containers executor proof of concept (FORGE-79)
Some checks failed
CI / gitleaks (pull_request) Successful in 10s
CI / storybook (pull_request) Successful in 1m43s
CI / unit-api (pull_request) Successful in 2m4s
CI / web-build (pull_request) Successful in 3m49s
CI / checks (pull_request) Successful in 3m57s
CI / unit-web (pull_request) Successful in 2m56s
CI / go (pull_request) Successful in 1m23s
CI / database (pull_request) Successful in 2m51s
CF executor smoke / smoke (pull_request) Failing after 15m1s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 35s
117d9cbebc
apps/ci-executor is a Worker plus Container class. Each container runs
the stock forgejo-runner v13 'one-job --wait' in host mode with the
'cloudflare' label: it claims one task over RunnerService, streams logs,
and exits so billing stops. The runner token arrives as a Worker secret,
is written to a private file for --token-url, and is unset from the
environment the job steps see. Phase 2 starts containers via an
authenticated POST /run; phase 3 adds the autoscaling pool.

The image (Node 24.14, pnpm 10.19, PostgreSQL 17, gitleaks 8.30.1,
forgejo-runner 13.0.0 pinned by sha256) is pushed to the Cloudflare
registry, because wrangler's own build passes --provenance, which podman
rejects.

cf-executor-smoke.yml runs a light job on 'cloudflare': checkout, the
gitleaks scan, and PostgreSQL started as a process, since host mode has
no service containers.

Runner #28 'cf-containers' is registered via a shared secret, scoped to
gmackie/ForgeGraph, label 'cloudflare'. Aligns with FORGE-67: executor
only, no control plane.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Owner

Preview environment is live: https://pr-686-forgegraph.forgegraf.com

Deployed 117d9cbe with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-686-forgegraph.forgegraf.com Deployed `117d9cbe` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
Author
Owner

Preview environment is live: https://pr-686-forgegraph.forgegraf.com

Deployed 117d9cbe with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-686-forgegraph.forgegraf.com Deployed `117d9cbe` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
gmackie force-pushed FORGE-79-cf-executor-poc from 117d9cbebc
Some checks failed
CI / gitleaks (pull_request) Successful in 10s
CI / storybook (pull_request) Successful in 1m43s
CI / unit-api (pull_request) Successful in 2m4s
CI / web-build (pull_request) Successful in 3m49s
CI / checks (pull_request) Successful in 3m57s
CI / unit-web (pull_request) Successful in 2m56s
CI / go (pull_request) Successful in 1m23s
CI / database (pull_request) Successful in 2m51s
CF executor smoke / smoke (pull_request) Failing after 15m1s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 35s
to 0c81e05fc7
All checks were successful
CI / gitleaks (pull_request) Successful in 10s
CF executor smoke / smoke (pull_request) Successful in 14s
CI / storybook (pull_request) Successful in 2m11s
CI / web-build (pull_request) Successful in 3m30s
CI / unit-api (pull_request) Successful in 2m49s
CI / checks (pull_request) Successful in 3m41s
CI / database (pull_request) Successful in 3m1s
CI / unit-web (pull_request) Successful in 3m38s
CI / go (pull_request) Successful in 1m23s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 15s
2026-10-12 03:27:03 +00:00
Compare
Author
Owner

Preview environment is live: https://pr-686-forgegraph.forgegraf.com

Deployed 0c81e05f with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-686-forgegraph.forgegraf.com Deployed `0c81e05f` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
gmackie force-pushed FORGE-79-cf-executor-poc from 0c81e05fc7
All checks were successful
CI / gitleaks (pull_request) Successful in 10s
CF executor smoke / smoke (pull_request) Successful in 14s
CI / storybook (pull_request) Successful in 2m11s
CI / web-build (pull_request) Successful in 3m30s
CI / unit-api (pull_request) Successful in 2m49s
CI / checks (pull_request) Successful in 3m41s
CI / database (pull_request) Successful in 3m1s
CI / unit-web (pull_request) Successful in 3m38s
CI / go (pull_request) Successful in 1m23s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 15s
to 93dc978960
All checks were successful
CI / gitleaks (pull_request) Successful in 18s
CF executor smoke / smoke (pull_request) Successful in 19s
CI / storybook (pull_request) Successful in 3m46s
CI / web-build (pull_request) Successful in 4m0s
CI / unit-api (pull_request) Successful in 2m44s
CI / unit-web (pull_request) Successful in 3m5s
CI / checks (pull_request) Successful in 4m20s
CI / go (pull_request) Successful in 1m18s
CI / database (pull_request) Successful in 2m44s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 10s
2026-10-12 03:40:08 +00:00
Compare
Author
Owner

Preview environment is live: https://pr-686-forgegraph.forgegraf.com

Deployed 93dc9789 with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-686-forgegraph.forgegraf.com Deployed `93dc9789` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
Sign in to join this conversation.
No description provided.