Repository navigation
Publish a workerd container image with each release - #8504
Conversation
There was a problem hiding this comment.
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-imagetested (.github/workflows/release.yml:404) - [INFO]
--version-onlyin docker/test.sh has no caller (docker/test.sh:25)
View full review
publish-imagerebuilds the multi-platform image with BuildKit in a container. It does not publish the single-platform images thattest-imagetested. 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-onlymode ofdocker/test.shis 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
70fb574 to
8ba455f
Compare
There was a problem hiding this comment.
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-imageandtag-image. Both run only on main and only whenDOCKER_HUB_USERNAMEis set. - Permissions:
id-token: writeis granted only topublish-image, for cosign.tag-imagedoes 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.ymlregex-checks the base image digest before it substitutes it. - Test container:
docker/test.shruns the container read-only, with all capabilities dropped,no-new-privilegesand 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-imagenow pushes and signs by digest only.verify-imagerunsdocker/test.shon that exact digest on amd64 and arm64 runners.tag-imagethen points<version>andlatest/betaat it and checks that each tag resolves to the signed digest. --version-onlyflag (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-binaryandLinux-ARM64-binaryinrelease.yml, andlinux-X64-binaryintest.yml. - The image jobs are chained through
needs. A skipped npm release skips them, and a digest that failsverify-imagestays 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
8ba455f to
c36f716
Compare
There was a problem hiding this comment.
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-imageandtag-image. - The third-party actions in those jobs are pinned by commit, and
id-token: writeis granted only topublish-image. - The version, digest and arch reach the shell steps through
env:, not through interpolation into the script. deps-updater.ymlchecks 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.shruns the container read-only, with all capabilities dropped andno-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
c36f716 to
dd4896f
Compare
There was a problem hiding this comment.
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-diris rejected when the config argument is a project directory, soworkerd 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_configstill guards--data-dirwith!wrangler::is_wrangler_config(&config_file), which only checks for a.jsonor.jsoncextension. A directory such as/appfails that check, soworkerd serve /app --data-dir=/dataexits with the usage error "only a wrangler config keeps its state there".serve /app/wrangler.json --data-dir=/dataworks, andnamed_configresolves/appto 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_dirtells the user to pass--data-dir, and doing that on the image fails.
- The entrypoint is
- Fix: base the guard on the resolved config, for example
binary || named_config(&config_file)returningNone. 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_configdoc comment listsserve,test,benchandcompilebut omitsfuzzilli, which also resolves configs throughload_config. (src/workerd/server/cli/wrangler.rs:430)
View full review
src/workerd/server/cli/wrangler.rs:430: the doc comment listsserve,test,benchandcompile, butfuzzillialso goes throughload_configand 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-imageandtag-image. - The third-party actions in those jobs are pinned by commit, and
id-token: writeis granted only topublish-image. - The version, digest and arch reach the shell steps through
env:, not through interpolation into the script. deps-updater.ymlchecks 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.shruns containers read-only, with all capabilities dropped.
📖 AGENTS.md: ✅ LGTM
No issues found.
⚡ Performance: ✅ LGTM
No performance concerns.
Reviewed commit: dd4896fe
* `<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.
dd4896f to
fac754d
Compare
There was a problem hiding this comment.
✅ 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
This publishes
docker.io/cloudflare/workerd, a minimal workerd image,with every npm release. An app's image is then
FROMit plus aCOPYof its Wrangler project, which is all a Kubernetes deployment needs.
cc-debian13:nonroot, pinned by digest, withonly
/usr/local/bin/workerdand an empty/data. It runs as65532:65532, has no shell or package manager, and works on a
read-only root filesystem.
/appon port 8080, so Kubernetesargs:only add flags.
docker/README.mdshows how to override the commandfor a capnp config or
workerd test. The project must set"no_bundle": true, since the image has no esbuild.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, asworkerd deployalready does. Adirectory was never a valid Cap'n Proto config, so no command line
changes meaning.
linux/amd64andlinux/arm64, built fromthe same release binaries that go to npm.
release.ymlpublishes it from main, after the platform packages andworkerdare on npm. The tags are<version>, pluslatestorbetaas on npm.attestations, and signed keyless with cosign. The README has the
cosign verifycommand.docker/test.shon it. It checks the image's user,--version,serving a
wrangler.jsonand awrangler.jsoncproject from aread-only root, and a Durable Object's state kept on a volume with
--data-dir=/dataappended, as the README shows. Only then do thetags move to the digest; one that fails stays untagged.
by commit.
test-linux's binary and runsdocker/test.sh. The weekly dependency update refreshes the baseimage 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,616requests with no failures.
The public
cloudflare/workerdrepository on Docker Hub, therepository variable
DOCKER_HUB_USERNAMEand the secretDOCKER_HUB_ACCESS_TOKENare in place; until the variable is set, theimage 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.
Comments in code files are counted with that file.