Skip to content

Publish a workerd container image with each release - #8504

Merged
piscisaureus merged 4 commits into
mainfrom
piscisaureus/docker-image
Nov 24, 2026
Merged

piscisaureus merged 4 commits into
mainfrom
piscisaureus/docker-image

Conversation

@piscisaureus

@piscisaureus piscisaureus commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

This publishes docker.io/cloudflare/workerd, a minimal workerd image,
with every npm release. An app's image is then FROM it plus a COPY
of its Wrangler project, which is all a Kubernetes deployment needs.

  • The image is distroless cc-debian13:nonroot, pinned by digest, with
    only /usr/local/bin/workerd and an empty /data. It runs as
    65532:65532, has no shell or package manager, and works on a
    read-only root filesystem.
  • It serves the project in /app on port 8080, so Kubernetes args:
    only add flags. docker/README.md shows how to override the command
    for a capnp config or workerd test. The project must set
    "no_bundle": true, since the image has no esbuild.
  • For that, workerd serve (and every command that takes a config)
    now also accepts a project directory, and reads its wrangler.json,
    or else its wrangler.jsonc, as workerd deploy already does. A
    directory was never a valid Cap'n Proto config, so no command line
    changes meaning.
  • It is one manifest for linux/amd64 and linux/arm64, built from
    the same release binaries that go to npm.
  • release.yml publishes it from main, after the platform packages and
    workerd are on npm. The tags are <version>, plus latest or
    beta as on npm.
  • The image is pushed by digest only, with SBOM and provenance
    attestations, and signed keyless with cosign. The README has the
    cosign verify command.
  • An amd64 and an arm64 runner then pull that digest and run
    docker/test.sh on it. It checks the image's user, --version,
    serving a wrangler.json and a wrangler.jsonc project from a
    read-only root, and a Durable Object's state kept on a volume with
    --data-dir=/data appended, as the README shows. Only then do the
    tags move to the digest; one that fails stays untagged.
  • The actions in the jobs that hold Docker Hub credentials are pinned
    by commit.
  • Every PR builds the amd64 image from test-linux's binary and runs
    docker/test.sh. The weekly dependency update refreshes the base
    image digest.

On a three-node GKE cluster, an app moved onto an image built from this
Dockerfile and then went through a rollout restart. It served 2,616
requests with no failures.

The public cloudflare/workerd repository on Docker Hub, the
repository variable DOCKER_HUB_USERNAME and the secret
DOCKER_HUB_ACCESS_TOKEN are in place; until the variable is set, the
image jobs are skipped. Before the first publish, "Test the container
image" should become a required check, so that an auto-merged base
digest update cannot break the image.

Kind Added Removed Where
Implementation 202 9 Dockerfile, publish jobs, deps-updater, CLI
Tests 256 1 test.sh, PR job, per-arch test, CLI tests
Documentation 160 2 docker/README.md, README.md, AGENTS.md

Comments in code files are counted with that file.

@piscisaureus
piscisaureus requested review from a team as code owners November 16, 2026 22:34
@piscisaureus
piscisaureus requested review from edmundhung and ry and removed request for ry November 16, 2026 22:34

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 8ba455fc.

This review, of 70fb574f

💬 Approved with comments — No blocking or warning-level issues. There are three informational notes: the published image is a rebuild, not the tested image; the actions that handle publish credentials are pinned by tag; and test.sh has an unused flag.

Findings: 3 info (3 are inline comments on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 2 info

The workflows and Dockerfile are consistent. There are two minor notes: the published image is rebuilt rather than the tested one, and --version-only has no caller.

Recommendation: 💬 Optional Nits

  • [INFO] The published multi-arch image is rebuilt separately from the images test-image tested (.github/workflows/release.yml:404)
  • [INFO] --version-only in docker/test.sh has no caller (docker/test.sh:25)
View full review
  • publish-image rebuilds the multi-platform image with BuildKit in a container. It does not publish the single-platform images that test-image tested. The inputs are the same and the build runs nothing, so the risk is low. Still, the signed digest is not the one that was tested.
  • The --version-only mode of docker/test.sh is documented, but no workflow or doc uses it.

I also checked these and they look correct: the artifact names match what the build uploads, COPY --chmod=755 restores the exec bit that artifacts lose, and the image jobs are skipped when tag-and-release is skipped.


🔒 Security: 💬 1 info

No exploitable issues. One hardening note on tag-pinned actions in the credentialed publish job.

Recommendation: 💬 Optional Nits

  • [INFO] Actions in the credentialed publish job are pinned by mutable tag (.github/workflows/release.yml:397)
View full review

The publish-image job holds DOCKER_HUB_ACCESS_TOKEN and id-token: write, and it uses docker/setup-buildx-action, docker/login-action, docker/build-push-action and sigstore/cosign-installer pinned by mutable major tags. That matches the rest of the repository's workflows, but pinning these four actions to commit SHAs would narrow the supply-chain exposure for this job.

I also checked these and they look correct: persist-credentials: false, minimal contents: read, values passed through env: rather than interpolated into scripts, runs restricted to main, the digest regex check in deps-updater.yml, and a test container that runs read-only with all capabilities dropped and its port bound to 127.0.0.1.


✅ All other checks passed

🚀 Release: ✅ LGTM

This adds a new publicly published artifact to the release pipeline. It is published after npm and gated on smoke tests for both platforms, and a failure leaves the npm release unaffected. Before the first publish, the Docker Hub repository, the DOCKER_HUB_USERNAME variable and the DOCKER_HUB_ACCESS_TOKEN secret must be set up, as the description lists.


📖 AGENTS.md: ✅ LGTM

No issues found.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

docker/README.md and the comments in the Dockerfile and workflows match the behaviour of the change.


Reviewed commit: 70fb574f

Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread docker/test.sh Resolved
@piscisaureus
piscisaureus requested a review from ry November 16, 2026 23:44
@piscisaureus
piscisaureus force-pushed the piscisaureus/docker-image branch from 70fb574 to 8ba455f Compare November 16, 2026 23:51

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of c36f716f.

This review, of 8ba455fc

✅ Approved — No findings at this commit. All three earlier notes are fixed: the image is tested by digest before it is tagged, the credentialed actions are pinned by commit, and the unused test.sh flag is gone.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Overall risk: Low. The image is published after npm, from the same release binaries. Its digest is tested on amd64 and arm64 before any tag moves, and a failure leaves the npm release alone. Before the first publish, the Docker Hub repository, the DOCKER_HUB_USERNAME variable and the DOCKER_HUB_ACCESS_TOKEN secret need to be set up, as the description lists.


🔒 Security: ✅ LGTM

The earlier note is fixed. docker/setup-buildx-action, docker/login-action, docker/build-push-action and sigstore/cosign-installer are now pinned by commit, with the version in a comment. BuildKit is pinned by digest too.

These points also check out:

  • Credentials: Docker Hub credentials appear only in publish-image and tag-image. Both run only on main and only when DOCKER_HUB_USERNAME is set.
  • Permissions: id-token: write is granted only to publish-image, for cosign. tag-image does not check out the repository.
  • Script injection: The version, digest and arch reach shell steps through env:, not through interpolation into the script.
  • Digest update: deps-updater.yml regex-checks the base image digest before it substitutes it.
  • Test container: docker/test.sh runs the container read-only, with all capabilities dropped, no-new-privileges and a localhost-only port.

📖 AGENTS.md: ✅ LGTM

No issues found.


📋 Code Quality: ✅ LGTM

🔄 Since last review: 3 findings resolved, 0 preserved, 0 new

I re-checked the two earlier notes at 8ba455f:

  • Rebuilt multi-arch image (release.yml): Fixed. publish-image now pushes and signs by digest only. verify-image runs docker/test.sh on that exact digest on amd64 and arm64 runners. tag-image then points <version> and latest/beta at it and checks that each tag resolves to the signed digest.
  • --version-only flag (docker/test.sh): Fixed. The flag is gone and the script now takes exactly the image and the platform.

These points also check out:

  • The artifact names match what the build uploads: Linux-X64-binary and Linux-ARM64-binary in release.yml, and linux-X64-binary in test.yml.
  • The image jobs are chained through needs. A skipped npm release skips them, and a digest that fails verify-image stays untagged.

⚡ Performance: ✅ LGTM

No performance concerns. The image is a single COPY layer on a distroless base, and the poll in docker/test.sh is bounded.


📝 Documentation: ✅ LGTM

docker/README.md and the workflow comments match the behaviour at this commit.


Reviewed commit: 8ba455fc

Comment thread docker/Dockerfile Resolved
Comment thread docker/README.md Resolved

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of dd4896fe.

This review, of c36f716f

✅ Approved — No findings at this commit. The new project-directory support in the CLI is correct and tested, and it fixes the wrangler.jsonc entrypoint problem raised earlier on the pull request.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

The image is published after npm, from the same release binaries. Its digest is tested on amd64 and arm64 before any tag moves, and a failure in the image jobs leaves the npm release alone. The project-directory support adds a new way to pass a config without changing any existing one, and the CLI tests and docker/test.sh cover it.


🔒 Security: ✅ LGTM

  • Docker Hub credentials appear only in publish-image and tag-image.
  • The third-party actions in those jobs are pinned by commit, and id-token: write is granted only to publish-image.
  • The version, digest and arch reach the shell steps through env:, not through interpolation into the script.
  • deps-updater.yml checks the base image digest against a regex before it substitutes it.
  • The image runs as non-root (65532) on a distroless base pinned by digest.
  • docker/test.sh runs the container read-only, with all capabilities dropped and no-new-privileges.

📖 AGENTS.md: ✅ LGTM

No issues found.


📋 Code Quality: ✅ LGTM

wrangler::named_config resolves a directory through project_config and keeps the existing checks for .json and .jsonc files. load_config passes the resolved path to wrangler::load and uses it in error messages. The --binary path returns before any of this runs. Tests cover the directory and file cases. In docker/test.sh, each container is cleaned up and the poll loop is bounded.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

README.md, docker/README.md and src/workerd/server/AGENTS.md match the behaviour at this commit.


Reviewed commit: c36f716f

@piscisaureus
piscisaureus force-pushed the piscisaureus/docker-image branch from c36f716 to dd4896f Compare November 24, 2026 15:13

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of fac754dc.

This review, of dd4896fe

💬 Approved with comments — One WARNING: --data-dir is rejected when the config argument is a project directory, which matters for the image's serve /app entrypoint. Also one documentation INFO.

Findings: 1 warning · 1 info (2 are inline comments on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #8504.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (1)

### [Code Quality] `--data-dir` is rejected when the config argument is a project directory, so `workerd serve /app --data-dir=/data` (the image's entrypoint plus a flag) fails with a usage error.
- **File:** src/workerd/server/cli/lib.rs:488

## INFO (1)

### [Documentation] The `named_config` doc comment lists `serve`, `test`, `bench` and `compile` but omits `fuzzilli`, which also resolves configs through `load_config`.
- **File:** src/workerd/server/cli/wrangler.rs:430

📋 Code Quality: ⚠️ 1 warning

--data-dir is rejected when the config argument is a project directory.

Recommendation: 📝 Minor Comments

  • [WARNING] --data-dir is rejected when the config argument is a project directory, so workerd serve /app --data-dir=/data (the image's entrypoint plus a flag) fails with a usage error. (src/workerd/server/cli/lib.rs:488)
View full review

--data-dir is rejected for a project directory (src/workerd/server/cli/lib.rs:460, wrangler.rs:404-407)

  • load_config still guards --data-dir with !wrangler::is_wrangler_config(&config_file), which only checks for a .json or .jsonc extension. A directory such as /app fails that check, so workerd serve /app --data-dir=/data exits with the usage error "only a wrangler config keeps its state there".
  • serve /app/wrangler.json --data-dir=/data works, and named_config resolves /app to that same file a few lines later. So the directory form behaves differently from the file form for this one flag.
  • The image makes this easy to hit:
    • The entrypoint is serve /app, and the image ships a writable /data.
    • The default state directory, /app/.wrangler/state/workerd, is read-only under --read-only.
    • create_state_dir tells the user to pass --data-dir, and doing that on the image fails.
  • Fix: base the guard on the resolved config, for example binary || named_config(&config_file) returning None. Add a test that a directory config accepts --data-dir.

📝 Documentation: 💬 1 info

The named_config doc comment omits fuzzilli.

Recommendation: 💬 Optional Nits

  • [INFO] The named_config doc comment lists serve, test, bench and compile but omits fuzzilli, which also resolves configs through load_config. (src/workerd/server/cli/wrangler.rs:430)
View full review
  • src/workerd/server/cli/wrangler.rs:430: the doc comment lists serve, test, bench and compile, but fuzzilli also goes through load_config and accepts a project directory.

✅ All other checks passed

🚀 Release: ✅ LGTM

The image is published after npm, from the same release binaries. Its digest is tested on amd64 and arm64 before any tag moves, and a failure in the image jobs leaves the npm release alone.


🔒 Security: ✅ LGTM

  • Docker Hub credentials appear only in publish-image and tag-image.
  • The third-party actions in those jobs are pinned by commit, and id-token: write is granted only to publish-image.
  • The version, digest and arch reach the shell steps through env:, not through interpolation into the script.
  • deps-updater.yml checks the base image digest against a regex before it substitutes it.
  • The image runs as non-root on a distroless base pinned by digest.
  • docker/test.sh runs containers read-only, with all capabilities dropped.

📖 AGENTS.md: ✅ LGTM

No issues found.


⚡ Performance: ✅ LGTM

No performance concerns.


Reviewed commit: dd4896fe

Comment thread src/workerd/server/cli/lib.rs Resolved
Comment thread src/workerd/server/cli/wrangler.rs Resolved
* `<config-file>` may be a directory. Every command that takes one
  (`serve`, `test`, `bench`, `compile` and `fuzzilli`) then uses its
  `wrangler.json`, else its `wrangler.jsonc`:
  `wrangler::project_config`, the lookup `deploy` already does. A
  directory with neither, or with only a `wrangler.toml`, is a usage
  error that says so.
* `wrangler::named_config` sorts the argument into a directory, a
  `.json` / `.jsonc` file, or a Cap'n Proto config. A directory was
  never a valid Cap'n Proto config, so no existing command line
  changes meaning.
* `--data-dir` applies to a directory as to the config file in it.
  The cluster test serves its wrangler project as a directory with
  `--data-dir`, as the container image does.
* `--help`, the README and `server/AGENTS.md` describe the directory
  form.
* `docker/Dockerfile` builds `docker.io/cloudflare/workerd`: the
  workerd binary at `/usr/local/bin/workerd` on
  `gcr.io/distroless/cc-debian13:nonroot`, pinned by digest, with an
  empty `/data` owned by `nonroot` (65532). It has no shell or package
  manager, runs as 65532:65532 and works on a read-only root
  filesystem. The binary links only glibc, but glibc's `backtrace()`
  loads `libgcc_s.so.1`, which `base-debian13` lacks, so the base is
  `cc`.
* Its entrypoint is `workerd serve /app --socket-addr=http=*:8080`,
  which serves the project's `wrangler.json`, else its
  `wrangler.jsonc`. An app's image is `FROM` it plus `COPY . /app/`,
  and container arguments only add flags.
* The build context holds a Linux binary per platform at
  `<arch>/workerd`, picked by `TARGETARCH`. The build runs nothing, so
  one host builds `linux/amd64` and `linux/arm64` without emulation.
* `docker/test.sh <image> <platform>` checks that the image's user is
  65532:65532, runs `workerd --version` in it, and serves two
  one-module wrangler projects from it, one with a `wrangler.json` and
  one with a `wrangler.jsonc`, with its own entrypoint and user on a
  read-only root, expecting a 200 from each. It then serves a project
  with a Durable Object counter as the README shows, with
  `--data-dir=/data` appended and a volume at `/data` the only
  writable path, and checks that the count goes on in a new container
  on that volume. The image may be a local one or a reference to pull,
  such as a digest.
* The weekly dependency update also refreshes the digest of the base
  image. A failed lookup only skips that with a warning; a `FROM` line
  it no longer recognizes fails the job.
* `docker/README.md` describes the image, building an app on it (which
  needs `"no_bundle": true`, since the image has no esbuild), running
  it read-only with its state on a named volume (`--data-dir=/data`),
  overriding the command, and debugging a pod with `kubectl debug`.
* Three jobs in `release.yml` publish `docker.io/cloudflare/workerd`
  once the `workerd` npm packages are published, and are skipped when
  they are not. A failure in them leaves the npm release alone.
* `publish-image` builds a `linux/amd64` + `linux/arm64` manifest list
  from the `Linux-X64-binary` and `Linux-ARM64-binary` artifacts, with
  an SBOM and a `mode=max` provenance attestation, and pushes it by
  digest only. cosign signs that digest keyless, with the workflow's
  GitHub OIDC token.
* `verify-image` pulls that digest on an amd64 and an arm64 runner and
  runs `docker/test.sh` on it, so the published bytes are what is
  tested, with no emulation.
* `tag-image` then points the tags at the digest and checks that each
  resolves to it. A digest that fails verification stays untagged.
* Tags: `<version>` always, plus `latest` for a release or `beta` for
  a prerelease (`0.` versions), as on npm.
* The build runs on BuildKit in a container pinned by digest, since
  the runner's Docker cannot push by digest. The third-party actions
  in the jobs that hold Docker Hub credentials are pinned by commit.
* The jobs run only on `main` and only once the repository variable
  `DOCKER_HUB_USERNAME` is set; the token is the secret
  `DOCKER_HUB_ACCESS_TOKEN`. Until then they are skipped.
* A `docker-image` job in `test.yml` builds the image for
  `linux/amd64` from the binary that `test-linux` uploads, and runs
  `docker/test.sh` on it: `workerd --version`, then a project with a
  `wrangler.json` and one with a `wrangler.jsonc`, each served from a
  read-only root as the image's user, expecting a 200.
* It runs on every pull request, not only on changes to `docker/`,
  since a change to workerd can break the image as well as a change
  to the Dockerfile. It needs no Bazel, runs on a standard runner and
  can only read the repository.
@piscisaureus
piscisaureus force-pushed the piscisaureus/docker-image branch from dd4896f to fac754d Compare November 24, 2026 18:15

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — Both earlier findings are fixed: --data-dir now works with a project directory, and the doc comment lists fuzzilli. No new issues in the CLI, image, workflow or documentation changes.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

The image is built from the same binaries that go to npm and published after them. Its digest is tested on amd64 and arm64 before any tag points to it, and a failure in the image jobs leaves the npm release alone.


🔒 Security: ✅ LGTM

Docker Hub credentials appear only in the publish and tag jobs, and the third-party actions in those jobs are pinned by commit. The image runs as non-root on a distroless base pinned by digest.


📖 AGENTS.md: ✅ LGTM

No issues found.


📋 Code Quality: ✅ LGTM

load_config now accepts --data-dir when the config is a directory, and named_config resolves the directory to the same file path the file form uses. wrangler-test.rs covers a directory, a file, a missing file and a capnp config. docker/test.sh checks that Durable Object state survives a new container on a volume.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No issues found.


Reviewed commit: fac754dc

@piscisaureus
piscisaureus merged commit 010066b into main Nov 24, 2026
39 of 40 checks passed
@piscisaureus
piscisaureus deleted the piscisaureus/docker-image branch November 24, 2026 19:29
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.

3 participants