Repository navigation
feat(containers): auto-detect content changes and tag/rebuild docker base images locally, for #8609 (#8612) [skip ci] - #8612
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
192c0fd to
497cd08
Compare
|
Rebased. Updated webimage hash (new here). Improved docs so the TL;DR shows, it may still need work. |
040fa43 to
17d199e
Compare
|
During this first phase, you have to push the tag with the hash using the normal github push technique (with the tag). In fact, with this, the hash is the only thing that matters to the local build. The branch name is just filler for context. |
26b8f07 to
2ce449b
Compare
|
Rebased. Updated the TL;DR to explain what has to be done (and what I just did for the rebase) |
…locally, for ddev#8609 - Addresses (Phase 1 of) ddev#8609 Changing a DDEV container image required three manually-coordinated steps: build+push to a hand-invented tag, hand-edit the matching tag constant in `pkg/versionconstants/versionconstants.go`, then rebuild the binary. Tags were computed two different ways (`containers/*/Makefile` used whole-repo `git describe --tags --always --dirty`; the binary's tag constants were separate hand-typed strings) and only lined up if a human reconciled them by hand. This was undocumented and effectively blocked external/forked contributors, since testing an image change locally still required editing the committed tag by hand. This is the local-dev-facing foundation only; CI/fork-safe push automation is deferred to a follow-up (Phase 2). - New `containers/hash-paths.sh` computes a deterministic content hash of a given set of paths (tracked + untracked-but-not-ignored files), correct for both committed and dirty working-tree state. - New `containers/autotag.sh` compares that hash against the one embedded in the tag currently committed in `pkg/versionconstants/versionconstants.go`. Unchanged: no-op, no Docker, no network. Changed: builds the image locally (host arch only, via its existing `images`/`container` target) unless already built at that tag, then rewrites just that tag's line in `versionconstants.go` in place. - Tag format is `<branch-name>-<hash>`: the hash (10 hex chars) is authoritative for all comparisons; the branch name is a cosmetic, automatically-computed hint tooling never parses. - Top-level `Makefile` gets a new `autotag-images` target (a prerequisite of `build:`) that runs this for all five images, and a `print-image-tags` target so a maintainer can read the exact tag to type into the existing (unchanged) `push-tagged-image.yml` / `push-tagged-dbimage.yml` `workflow_dispatch` `tag` input. - `ddev-dbserver` is a special case: one tag (`BaseDBTag`) covers ~19 db type/version image variants sharing the same directory, so only the default variant (`mariadb_11.8`) is auto-built locally; other variants still use the existing manual `make <target> VERSION=...`. - Removed 4 stale commented-out lines in the top-level `Makefile` referencing symbol names (`DBTag`, `RouterTag`, `DBATag`) that no longer exist in `versionconstants.go`. - Deleted `nightly_build.mak`: confirmed via repo-wide search to have zero references from any workflow, script, or doc, and already broken (same stale symbol names). Last touched years ago, predating the current `containers/` layout. - Bootstrapped all five image tags in this same PR by running `make` once, so `pkg/versionconstants/versionconstants.go` now carries real `<branch>-<hash>` tags rather than the old hand-typed strings. - Updated `docs/content/developers/building-contributing.md` and `docs/content/developers/release-management.md` to describe the new flow and `make print-image-tags`. CI is unaffected: `make test`/`testcmd`/`testddevapp` (what Buildkite and the GitHub binary-build workflow run) depend on the raw per-arch build target, not `build:`, so `autotag-images` never runs as a CI side effect. CI keeps compiling against whatever tag is already committed in `versionconstants.go`, exactly as today - a maintainer still needs to push that exact tag via the existing (unchanged) `push-tagged-image.yml`/`push-tagged-dbimage.yml` before CI can pull it, same as before. Fork contributors still can't push to `ddev/*` themselves; closing that gap is Phase 2. 1. Edit any file under `containers/ddev-webserver/` (or another image directory). 2. Run `make` from the repository root. 3. Confirm `docker images` shows a new local `ddev/ddev-webserver:<branch>-<hash>` image and `git diff pkg/versionconstants/versionconstants.go` shows only `WebTag` changed. 4. Run `make` again with no further edits - confirm it's fast/no-op (hash now matches the committed tag). 5. Run `ddev start` on a test project and confirm it uses the local image without attempting a pull. 6. Run `make print-image-tags` and confirm the printed values match what's committed. No new Go tests were added; this is build-tooling (Makefile/shell) with no ddev binary behavior change beyond the tag values it embeds. Existing tests that reference the tag constants (`pkg/ddevapp/compose_yaml_test.go`, `cmd/ddev/cmd/cmd_version_test.go`, `pkg/dockerutil/docker_compose_test.go`) read the constants dynamically rather than asserting a hardcoded value, so they're unaffected by the new tag format. Verified manually per the steps above, including a full `ddev start`/`ddev delete` cycle against a scratch project. No CI or release workflow changes. The existing `push-tagged-image.yml`/`push-tagged-dbimage.yml` workflows are untouched and still require a maintainer to manually trigger them with a tag (now obtainable via `make print-image-tags`) before a pushed image is available to pull. Forked-PR contributors still cannot push images themselves; that's targeted by a planned follow-up (Phase 2). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MMiHJAL7r6z29tAWiqguhA
- Follow-up to the content-addressed image tagging change (fixes ddev#8609, Phase 1) - it had no automated test coverage. - New `containers/autotag_test.sh` unit-tests hash-paths.sh/autotag.sh against a scratch git repository and a stubbed `docker` (no real image builds, no real Docker daemon interaction), covering: determinism, dirty-tree/untracked-file sensitivity, `.gitignore` handling, `--print-only`, build-on-change, the local-image-already- exists dedup path, file rewrite (including preserving trailing comments), and - the central design property - that the unchanged/ no-op path makes zero `docker` calls. - Fixed `containers/autotag.sh` to resolve `REPO_ROOT` from the caller's ambient working directory (`git rev-parse --show-toplevel`), matching `hash-paths.sh`, instead of anchoring it to the script's own on-disk location. Production behavior is unchanged (Make always invokes it with cwd at the repo root), but this is what makes it possible to point the script at a throwaway scratch repo in a test. - Wired the new test into `.github/workflows/container-tests.yml` as a small, fast, standalone job (no Docker/mkcert/Homebrew setup needed) so it runs on the same existing triggers (PRs touching `containers/**`, push to main, nightly schedule) - no new triggers or secrets added. ```bash containers/autotag_test.sh ``` Should print a `PASS:` line for every check and exit 0. This commit *is* the automated test coverage; it also re-verified the end-to-end `make`/`make print-image-tags` flow still works against the real repo after the `autotag.sh` fix. Test-only change plus a one-line behavior-preserving fix in `autotag.sh`. No CI secrets, triggers, or push/build automation added. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MMiHJAL7r6z29tAWiqguhA
The tags bootstrapped by the initial commit used the branch name this work was originally committed on (20260721_rfay_reimplement_dbimage) before it was moved to its own branch (20260721_rfay_content_addressed_image_tags). The content hashes were unaffected by the move (branch name is cosmetic), so `make` never re-triggered a rebuild, but the images actually pushed to Docker Hub for this PR used the new branch name as their prefix. Update the committed tags to the exact strings that are live on `ddev/*`, so `docker pull` finds them. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MMiHJAL7r6z29tAWiqguhA
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…dits Co-Authored-By: Claude Sonnet 5 <[email protected]>
d1dca98 to
2a44c20
Compare
2a44c20 to
2c3f845
Compare
stasadev
left a comment
There was a problem hiding this comment.
Looks good to me. Quite impressive work!
As far as I understand, it doesn't matter what comes before the hash in the first part of the tag name.
I changed it like this, ran make autotag-images, and it didn't detect any changes:
-var SSHAuthTag = "20260721_rfay_content_addressed_image_tags-8e8bf1217c"
+var SSHAuthTag = "v1.25.3-8e8bf1217c"
The first part of the tag name is ignored, it's only there for human reading, but the auto-tag uses only the hash. |
…ware CI/Buildkite, for ddev#8609 ## Short Summary (TL;DR) Phase 2 of ddev#8609: CI now detects a changed container image, waits for a maintainer's approval, and builds/pushes it automatically for both maintainer and fork PRs, without ever exposing the DockerHub push token to a job that runs fork-supplied build content. Buildkite no longer races the push. ## The Issue - Phase 2 of ddev#8609 Phase 1 (ddev#8612) gave every image a content-addressed tag and made `make` auto-build changed images locally. The CI/registry side was untouched: a maintainer still had to notice a container changed and manually run `push-tagged-image.yml`/`push-tagged-dbimage.yml`, and fork contributors couldn't get an image change pushed without a maintainer doing it by hand. ## How This PR Solves The Issue Two new workflows split build from push so a push secret never shares a job with untrusted (fork) build content: - `image-build-push.yml` (untrusted side, no secrets anywhere): a `detect` job recomputes each image's real content hash and checks the registry directly (never trusting the tag string committed in `versionconstants.go`, so a fork can't forge it); an `approval` job gates on the new `image-push` GitHub Environment before any expensive/untrusted build work runs; a `build` job builds per-arch using the same local-build Makefile targets Phase 1's `autotag-images` already uses, then uploads a `docker save` tarball plus tag metadata as an artifact. - `image-push.yml` (trusted side): triggered by `workflow_run` once the build workflow completes, so it always runs the default-branch version of itself and never checks out or executes the PR's code. It downloads the artifact, re-validates the tag against a strict format + reserved-tag blocklist (`containers/validate-image-tag.sh`), loads and pushes each per-arch image, assembles the multi-arch manifest, and comments on the PR. New scripts: `containers/registry-tag-exists.sh` (registry existence check, the same `docker buildx imagetools inspect` idiom already used in the post-push wait-loop) and `containers/validate-image-tag.sh`, both with bash test harnesses matching `containers/autotag_test.sh`'s style. Buildkite gets a `.buildkite/wait-for-images.sh` self-guarding step (wired into `test.sh`/`perf.sh`) that polls the registry for the tags a checkout actually needs before pulling anything, instead of racing the push - implementing the "lighter" option from the issue's open Buildkite decision. The existing `push-tagged-image.yml`/`push-tagged-dbimage.yml` are untouched and remain for manual re-pushes and the 18 `ddev-dbserver` variants Phase 1 doesn't auto-build. ## Manual Testing Instructions Requires one-time setup on the test repo (see `release-management.md`'s new "One-time setup" section): create a GitHub Environment named `image-push` with required reviewers, and add `PUSH_SERVICE_ACCOUNT_TOKEN` as a secret scoped to that environment. 1. Run the new unit tests directly: `containers/registry_tag_exists_test.sh` and `containers/validate_image_tag_test.sh` (no Docker daemon or network needed). 2. On a test repo (`image-push.yml` must be on its default branch - `workflow_run` triggers only fire for the default-branch copy of the listening workflow), push a trivial change to `containers/ddev-xhgui/` on a branch and open a PR. Confirm: `detect` flags it, `approval` blocks `build` until a reviewer approves, `build` produces artifacts with no secrets referenced in that job, `image-push` fires on completion (its own approval), loads and pushes the image, and comments on the PR. 3. Negative test: hand-edit `versionconstants.go` on that branch to a bogus `latest-<fakehash>`-shaped tag and confirm `detect` ignores it (recomputes the real hash from content) and that `containers/validate-image-tag.sh` rejects a manufactured `latest`/`vX.Y.Z` tag directly. ## Automated Testing Overview Two new bash test harnesses (`containers/registry_tag_exists_test.sh`, `containers/validate_image_tag_test.sh`) stub `docker`/use pure string checks, no daemon or network required, wired into `container-tests.yml`'s existing unit-test job alongside `autotag_test.sh`. No Go code changed. ## Release/Deployment Notes No behavior change for anyone not touching `containers/`. Requires one-time manual GitHub Environment setup (documented) before the automatic push path is live on a given repo; until then `detect`/`approval`/`build` still run harmlessly (approval job would just wait indefinitely with no reviewers configured). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…ware CI/Buildkite, for ddev#8609 Phase 2 of ddev#8609: CI now detects a changed container image, waits for a maintainer's approval, and builds/pushes it automatically for both maintainer and fork PRs, without ever exposing the DockerHub push token to a job that runs fork-supplied build content. Buildkite no longer races the push. - Phase 2 of ddev#8609 Phase 1 (ddev#8612) gave every image a content-addressed tag and made `make` auto-build changed images locally. The CI/registry side was untouched: a maintainer still had to notice a container changed and manually run `push-tagged-image.yml`/`push-tagged-dbimage.yml`, and fork contributors couldn't get an image change pushed without a maintainer doing it by hand. Two new workflows split build from push so a push secret never shares a job with untrusted (fork) build content: - `image-build-push.yml` (untrusted side, no secrets anywhere): a `detect` job recomputes each image's real content hash and checks the registry directly (never trusting the tag string committed in `versionconstants.go`, so a fork can't forge it); an `approval` job gates on the new `image-push` GitHub Environment before any expensive/untrusted build work runs; a `build` job builds per-arch using the same local-build Makefile targets Phase 1's `autotag-images` already uses, then uploads a `docker save` tarball plus tag metadata as an artifact. - `image-push.yml` (trusted side): triggered by `workflow_run` once the build workflow completes, so it always runs the default-branch version of itself and never checks out or executes the PR's code. It downloads the artifact, re-validates the tag against a strict format + reserved-tag blocklist (`containers/validate-image-tag.sh`), loads and pushes each per-arch image, assembles the multi-arch manifest, and comments on the PR. New scripts: `containers/registry-tag-exists.sh` (registry existence check, the same `docker buildx imagetools inspect` idiom already used in the post-push wait-loop) and `containers/validate-image-tag.sh`, both with bash test harnesses matching `containers/autotag_test.sh`'s style. Buildkite gets a `.buildkite/wait-for-images.sh` self-guarding step (wired into `test.sh`/`perf.sh`) that polls the registry for the tags a checkout actually needs before pulling anything, instead of racing the push - implementing the "lighter" option from the issue's open Buildkite decision. The existing `push-tagged-image.yml`/`push-tagged-dbimage.yml` are untouched and remain for manual re-pushes and the 18 `ddev-dbserver` variants Phase 1 doesn't auto-build. Requires one-time setup on the test repo (see `release-management.md`'s new "One-time setup" section): create a GitHub Environment named `image-push` with required reviewers, and add `PUSH_SERVICE_ACCOUNT_TOKEN` as a secret scoped to that environment. 1. Run the new unit tests directly: `containers/registry_tag_exists_test.sh` and `containers/validate_image_tag_test.sh` (no Docker daemon or network needed). 2. On a test repo (`image-push.yml` must be on its default branch - `workflow_run` triggers only fire for the default-branch copy of the listening workflow), push a trivial change to `containers/ddev-xhgui/` on a branch and open a PR. Confirm: `detect` flags it, `approval` blocks `build` until a reviewer approves, `build` produces artifacts with no secrets referenced in that job, `image-push` fires on completion (its own approval), loads and pushes the image, and comments on the PR. 3. Negative test: hand-edit `versionconstants.go` on that branch to a bogus `latest-<fakehash>`-shaped tag and confirm `detect` ignores it (recomputes the real hash from content) and that `containers/validate-image-tag.sh` rejects a manufactured `latest`/`vX.Y.Z` tag directly. Two new bash test harnesses (`containers/registry_tag_exists_test.sh`, `containers/validate_image_tag_test.sh`) stub `docker`/use pure string checks, no daemon or network required, wired into `container-tests.yml`'s existing unit-test job alongside `autotag_test.sh`. No Go code changed. No behavior change for anyone not touching `containers/`. Requires one-time manual GitHub Environment setup (documented) before the automatic push path is live on a given repo; until then `detect`/`approval`/`build` still run harmlessly (approval job would just wait indefinitely with no reviewers configured). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…ware CI/Buildkite, for ddev#8609 Phase 2 of ddev#8609: CI now detects a changed container image, waits for a maintainer's approval, and builds/pushes it automatically for both maintainer and fork PRs, without ever exposing the DockerHub push token to a job that runs fork-supplied build content. Buildkite no longer races the push. - Phase 2 of ddev#8609 Phase 1 (ddev#8612) gave every image a content-addressed tag and made `make` auto-build changed images locally. The CI/registry side was untouched: a maintainer still had to notice a container changed and manually run `push-tagged-image.yml`/`push-tagged-dbimage.yml`, and fork contributors couldn't get an image change pushed without a maintainer doing it by hand. Two new workflows split build from push so a push secret never shares a job with untrusted (fork) build content: - `image-build-push.yml` (untrusted side, no secrets anywhere): a `detect` job recomputes each image's real content hash and checks the registry directly (never trusting the tag string committed in `versionconstants.go`, so a fork can't forge it); an `approval` job gates on the new `image-push` GitHub Environment before any expensive/untrusted build work runs; a `build` job builds per-arch using the same local-build Makefile targets Phase 1's `autotag-images` already uses, then uploads a `docker save` tarball plus tag metadata as an artifact. - `image-push.yml` (trusted side): triggered by `workflow_run` once the build workflow completes, so it always runs the default-branch version of itself and never checks out or executes the PR's code. It downloads the artifact, re-validates the tag against a strict format + reserved-tag blocklist (`containers/validate-image-tag.sh`), loads and pushes each per-arch image, assembles the multi-arch manifest, and comments on the PR. New scripts: `containers/registry-tag-exists.sh` (registry existence check, the same `docker buildx imagetools inspect` idiom already used in the post-push wait-loop) and `containers/validate-image-tag.sh`, both with bash test harnesses matching `containers/autotag_test.sh`'s style. Buildkite gets a `.buildkite/wait-for-images.sh` self-guarding step (wired into `test.sh`/`perf.sh`) that polls the registry for the tags a checkout actually needs before pulling anything, instead of racing the push - implementing the "lighter" option from the issue's open Buildkite decision. The existing `push-tagged-image.yml`/`push-tagged-dbimage.yml` are untouched and remain for manual re-pushes and the 18 `ddev-dbserver` variants Phase 1 doesn't auto-build. Requires one-time setup on the test repo (see `release-management.md`'s new "One-time setup" section): create a GitHub Environment named `image-push` with required reviewers, and add `PUSH_SERVICE_ACCOUNT_TOKEN` as a secret scoped to that environment. 1. Run the new unit tests directly: `containers/registry_tag_exists_test.sh` and `containers/validate_image_tag_test.sh` (no Docker daemon or network needed). 2. On a test repo (`image-push.yml` must be on its default branch - `workflow_run` triggers only fire for the default-branch copy of the listening workflow), push a trivial change to `containers/ddev-xhgui/` on a branch and open a PR. Confirm: `detect` flags it, `approval` blocks `build` until a reviewer approves, `build` produces artifacts with no secrets referenced in that job, `image-push` fires on completion (its own approval), loads and pushes the image, and comments on the PR. 3. Negative test: hand-edit `versionconstants.go` on that branch to a bogus `latest-<fakehash>`-shaped tag and confirm `detect` ignores it (recomputes the real hash from content) and that `containers/validate-image-tag.sh` rejects a manufactured `latest`/`vX.Y.Z` tag directly. Two new bash test harnesses (`containers/registry_tag_exists_test.sh`, `containers/validate_image_tag_test.sh`) stub `docker`/use pure string checks, no daemon or network required, wired into `container-tests.yml`'s existing unit-test job alongside `autotag_test.sh`. No Go code changed. No behavior change for anyone not touching `containers/`. Requires one-time manual GitHub Environment setup (documented) before the automatic push path is live on a given repo; until then `detect`/`approval`/`build` still run harmlessly (approval job would just wait indefinitely with no reviewers configured). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…ware CI/Buildkite, for ddev#8609 Phase 2 of ddev#8609: CI now detects a changed container image, waits for a maintainer's approval, and builds/pushes it automatically for both maintainer and fork PRs, without ever exposing the DockerHub push token to a job that runs fork-supplied build content. Buildkite no longer races the push. - Phase 2 of ddev#8609 Phase 1 (ddev#8612) gave every image a content-addressed tag and made `make` auto-build changed images locally. The CI/registry side was untouched: a maintainer still had to notice a container changed and manually run `push-tagged-image.yml`/`push-tagged-dbimage.yml`, and fork contributors couldn't get an image change pushed without a maintainer doing it by hand. Two new workflows split build from push so a push secret never shares a job with untrusted (fork) build content: - `image-build-push.yml` (untrusted side, no secrets anywhere): a `detect` job recomputes each image's real content hash and checks the registry directly (never trusting the tag string committed in `versionconstants.go`, so a fork can't forge it); an `approval` job gates on the new `image-push` GitHub Environment before any expensive/untrusted build work runs; a `build` job builds per-arch using the same local-build Makefile targets Phase 1's `autotag-images` already uses, then uploads a `docker save` tarball plus tag metadata as an artifact. - `image-push.yml` (trusted side): triggered by `workflow_run` once the build workflow completes, so it always runs the default-branch version of itself and never checks out or executes the PR's code. It downloads the artifact, re-validates the tag against a strict format + reserved-tag blocklist (`containers/validate-image-tag.sh`), loads and pushes each per-arch image, assembles the multi-arch manifest, and comments on the PR. New scripts: `containers/registry-tag-exists.sh` (registry existence check, the same `docker buildx imagetools inspect` idiom already used in the post-push wait-loop) and `containers/validate-image-tag.sh`, both with bash test harnesses matching `containers/autotag_test.sh`'s style. Buildkite gets a `.buildkite/wait-for-images.sh` self-guarding step (wired into `test.sh`/`perf.sh`) that polls the registry for the tags a checkout actually needs before pulling anything, instead of racing the push - implementing the "lighter" option from the issue's open Buildkite decision. The existing `push-tagged-image.yml`/`push-tagged-dbimage.yml` are untouched and remain for manual re-pushes and the 18 `ddev-dbserver` variants Phase 1 doesn't auto-build. Requires one-time setup on the test repo (see `release-management.md`'s new "One-time setup" section): create a GitHub Environment named `image-push` with required reviewers, and add `PUSH_SERVICE_ACCOUNT_TOKEN` as a secret scoped to that environment. 1. Run the new unit tests directly: `containers/registry_tag_exists_test.sh` and `containers/validate_image_tag_test.sh` (no Docker daemon or network needed). 2. On a test repo (`image-push.yml` must be on its default branch - `workflow_run` triggers only fire for the default-branch copy of the listening workflow), push a trivial change to `containers/ddev-xhgui/` on a branch and open a PR. Confirm: `detect` flags it, `approval` blocks `build` until a reviewer approves, `build` produces artifacts with no secrets referenced in that job, `image-push` fires on completion (its own approval), loads and pushes the image, and comments on the PR. 3. Negative test: hand-edit `versionconstants.go` on that branch to a bogus `latest-<fakehash>`-shaped tag and confirm `detect` ignores it (recomputes the real hash from content) and that `containers/validate-image-tag.sh` rejects a manufactured `latest`/`vX.Y.Z` tag directly. Two new bash test harnesses (`containers/registry_tag_exists_test.sh`, `containers/validate_image_tag_test.sh`) stub `docker`/use pure string checks, no daemon or network required, wired into `container-tests.yml`'s existing unit-test job alongside `autotag_test.sh`. No Go code changed. No behavior change for anyone not touching `containers/`. Requires one-time manual GitHub Environment setup (documented) before the automatic push path is live on a given repo; until then `detect`/`approval`/`build` still run harmlessly (approval job would just wait indefinitely with no reviewers configured). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…8609 GetDBImage() builds every variant's reference from one shared BaseDBTag, so a change under containers/ddev-dbserver moves the tag for all 20 at once. But `make` built only mariadb_11.8 and the automatic flow pushed only ddev-dbserver-mariadb-11.8, leaving the other 19 referenced at a tag that existed nowhere. TestDdevAllDatabases and every test pinning a non-default database (db_test.go, snapshot_test.go, config_test.go, debug-migrate-database_test.go) would fail after any dbserver change. Introduced by phase 1 (ddev#8612): before that, BaseDBTag was hand-bumped after someone ran push-tagged-dbimage.yml for all 20, so the tag never moved ahead of the images. detect's matrix now covers every variant. It emits one entry per (image, arch) rather than a cross product, because the four oldest variants are amd64-only, and create-manifests takes its arch list from detect instead of assuming both. Artifact names key on repo_suffix rather than make_dir, which all 20 db variants share and would have collided on. wait-for-images.sh now fails fast, naming the command to run, when a non-locally-built image is out of date. Those 19 variants have no local fallback, and the tag `make` would invent depends on the runner's branch name (detached HEAD on a PR checkout), so it need not match what CI pushed. The variant list was duplicated four ways - this Makefile's three target lists, push-tagged-dbimage.yml's matrix and MULTI_ARCH_IMAGES, its multi-arch case statement, and image-configs.sh. It now lives in containers/ddev-dbserver/variants.txt, rendered per consumer by variants.sh. The generated lists are byte-identical to the ones they replace, verified for both host arches. validate-image-repo.sh drops its name pattern for the exact list, so a correctly-shaped repository that isn't published can't slip past. variants.txt sits inside the hashed dbserver directory deliberately: adding a database version has to change the content hash, or detect would find the tag already present and never build the new variant. That also means this commit moves BaseDBTag, so CI has to push all 20 variants before the non-default database tests can pass - the first live exercise of the fix. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ware CI/Buildkite, for ddev#8609 Phase 2 of ddev#8609: CI now detects a changed container image, waits for a maintainer's approval, and builds/pushes it automatically for both maintainer and fork PRs, without ever exposing the DockerHub push token to a job that runs fork-supplied build content. Buildkite no longer races the push. - Phase 2 of ddev#8609 Phase 1 (ddev#8612) gave every image a content-addressed tag and made `make` auto-build changed images locally. The CI/registry side was untouched: a maintainer still had to notice a container changed and manually run `push-tagged-image.yml`/`push-tagged-dbimage.yml`, and fork contributors couldn't get an image change pushed without a maintainer doing it by hand. Two new workflows split build from push so a push secret never shares a job with untrusted (fork) build content: - `image-build-push.yml` (untrusted side, no secrets anywhere): a `detect` job recomputes each image's real content hash and checks the registry directly (never trusting the tag string committed in `versionconstants.go`, so a fork can't forge it); an `approval` job gates on the new `image-push` GitHub Environment before any expensive/untrusted build work runs; a `build` job builds per-arch using the same local-build Makefile targets Phase 1's `autotag-images` already uses, then uploads a `docker save` tarball plus tag metadata as an artifact. - `image-push.yml` (trusted side): triggered by `workflow_run` once the build workflow completes, so it always runs the default-branch version of itself and never checks out or executes the PR's code. It downloads the artifact, re-validates the tag against a strict format + reserved-tag blocklist (`containers/validate-image-tag.sh`), loads and pushes each per-arch image, assembles the multi-arch manifest, and comments on the PR. New scripts: `containers/registry-tag-exists.sh` (registry existence check, the same `docker buildx imagetools inspect` idiom already used in the post-push wait-loop) and `containers/validate-image-tag.sh`, both with bash test harnesses matching `containers/autotag_test.sh`'s style. Buildkite gets a `.buildkite/wait-for-images.sh` self-guarding step (wired into `test.sh`/`perf.sh`) that polls the registry for the tags a checkout actually needs before pulling anything, instead of racing the push - implementing the "lighter" option from the issue's open Buildkite decision. The existing `push-tagged-image.yml`/`push-tagged-dbimage.yml` are untouched and remain for manual re-pushes and the 18 `ddev-dbserver` variants Phase 1 doesn't auto-build. Requires one-time setup on the test repo (see `release-management.md`'s new "One-time setup" section): create a GitHub Environment named `image-push` with required reviewers, and add `PUSH_SERVICE_ACCOUNT_TOKEN` as a secret scoped to that environment. 1. Run the new unit tests directly: `containers/registry_tag_exists_test.sh` and `containers/validate_image_tag_test.sh` (no Docker daemon or network needed). 2. On a test repo (`image-push.yml` must be on its default branch - `workflow_run` triggers only fire for the default-branch copy of the listening workflow), push a trivial change to `containers/ddev-xhgui/` on a branch and open a PR. Confirm: `detect` flags it, `approval` blocks `build` until a reviewer approves, `build` produces artifacts with no secrets referenced in that job, `image-push` fires on completion (its own approval), loads and pushes the image, and comments on the PR. 3. Negative test: hand-edit `versionconstants.go` on that branch to a bogus `latest-<fakehash>`-shaped tag and confirm `detect` ignores it (recomputes the real hash from content) and that `containers/validate-image-tag.sh` rejects a manufactured `latest`/`vX.Y.Z` tag directly. Two new bash test harnesses (`containers/registry_tag_exists_test.sh`, `containers/validate_image_tag_test.sh`) stub `docker`/use pure string checks, no daemon or network required, wired into `container-tests.yml`'s existing unit-test job alongside `autotag_test.sh`. No Go code changed. No behavior change for anyone not touching `containers/`. Requires one-time manual GitHub Environment setup (documented) before the automatic push path is live on a given repo; until then `detect`/`approval`/`build` still run harmlessly (approval job would just wait indefinitely with no reviewers configured). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…8609 GetDBImage() builds every variant's reference from one shared BaseDBTag, so a change under containers/ddev-dbserver moves the tag for all 20 at once. But `make` built only mariadb_11.8 and the automatic flow pushed only ddev-dbserver-mariadb-11.8, leaving the other 19 referenced at a tag that existed nowhere. TestDdevAllDatabases and every test pinning a non-default database (db_test.go, snapshot_test.go, config_test.go, debug-migrate-database_test.go) would fail after any dbserver change. Introduced by phase 1 (ddev#8612): before that, BaseDBTag was hand-bumped after someone ran push-tagged-dbimage.yml for all 20, so the tag never moved ahead of the images. detect's matrix now covers every variant. It emits one entry per (image, arch) rather than a cross product, because the four oldest variants are amd64-only, and create-manifests takes its arch list from detect instead of assuming both. Artifact names key on repo_suffix rather than make_dir, which all 20 db variants share and would have collided on. wait-for-images.sh now fails fast, naming the command to run, when a non-locally-built image is out of date. Those 19 variants have no local fallback, and the tag `make` would invent depends on the runner's branch name (detached HEAD on a PR checkout), so it need not match what CI pushed. The variant list was duplicated four ways - this Makefile's three target lists, push-tagged-dbimage.yml's matrix and MULTI_ARCH_IMAGES, its multi-arch case statement, and image-configs.sh. It now lives in containers/ddev-dbserver/variants.txt, rendered per consumer by variants.sh. The generated lists are byte-identical to the ones they replace, verified for both host arches. validate-image-repo.sh drops its name pattern for the exact list, so a correctly-shaped repository that isn't published can't slip past. variants.txt sits inside the hashed dbserver directory deliberately: adding a database version has to change the content hash, or detect would find the tag already present and never build the new variant. That also means this commit moves BaseDBTag, so CI has to push all 20 variants before the non-default database tests can pass - the first live exercise of the fix. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The Issue
TL;DR:
makeversionconstants.go.git diff rfay/20260721_rfay_content_addressed_image_tags pkg/versionconstants.goBefore, changing a DDEV container image meant build+push to a
hand-invented tag, hand-edit the matching tag constant in
versionconstants.go, then rebuild — three steps that only worked if ahuman kept them in sync. Now: edit the image's files, run
make, done.makehashes the image's content, and if it changed, builds it locallyand rewrites the tag itself — no invented tag, no hand-edit, no-op if
nothing changed.
This is phase 1. In phase 2, github actions will take care of pushing changed images.
Changing a DDEV container image required three manually-coordinated
steps: build+push the image to a hand-invented tag, hand-edit the
matching tag constant in
pkg/versionconstants/versionconstants.go,then rebuild the binary. Tags were computed two different ways
(
containers/*/Makefileused whole-repogit describe --tags --always --dirty; the binary's tag constants were separate hand-typed strings)and only lined up if a human reconciled them by hand. This was
undocumented and effectively blocked external/forked contributors,
since testing an image change locally still required editing the
committed tag by hand.
This PR is the local-dev-facing foundation only (Phase 1 of #8609).
CI/fork-safe push automation (a build/push split with GitHub
Environment approval gates so forked contributors can get their image
changes into CI without a maintainer manually pushing on their behalf)
is deferred to a follow-up PR (Phase 2).
How This PR Solves The Issue
containers/hash-paths.shcomputes a deterministic content hashof a given set of paths (tracked + untracked-but-not-ignored files),
correct for both committed and dirty working-tree state.
containers/autotag.shcompares that hash against the oneembedded in the tag currently committed in
pkg/versionconstants/versionconstants.go. Unchanged: no-op, noDocker, no network. Changed: builds the image locally (host arch
only) unless already built at that tag, then rewrites just that
tag's line in
versionconstants.goin place.<branch-name>-<hash>: the hash (10 hex chars) isauthoritative for all comparisons; the branch name is a cosmetic,
automatically-computed hint tooling never parses.
Makefilegets a newautotag-imagestarget (aprerequisite of
build:) that runs this for all five images, and aprint-image-tagstarget so a maintainer can read the exact tag totype into the existing (unchanged)
push-tagged-image.yml/push-tagged-dbimage.ymlworkflow_dispatchtaginput.ddev-dbserveris a special case: one tag (BaseDBTag) covers ~19db type/version image variants sharing the same directory, so only
the default variant (
mariadb_11.8) is auto-built locally; othervariants still use the existing manual
make <target> VERSION=....Makefilereferencing symbol names (
DBTag,RouterTag,DBATag) that nolonger exist in
versionconstants.go, and deletednightly_build.mak(confirmed unreferenced anywhere, and already broken with the same
stale symbol names).
corresponding images to
ddev/*via the existingpush-tagged-image.yml/push-tagged-dbimage.ymlworkflows, sopkg/versionconstants/versionconstants.gonow points at real,live, multi-arch images rather than the old hand-typed strings.
containers/autotag_test.sh, a unit test for the hash/taglogic against a scratch git repo and a stubbed
docker(no realbuilds), wired into
.github/workflows/container-tests.ymlas asmall standalone job on the existing triggers.
CI is otherwise unaffected:
make test/testcmd/testddevapp(whatBuildkite and the GitHub binary-build workflow run) depend on the raw
per-arch build target, not
build:, soautotag-imagesnever runs asa CI side effect. CI just compiles against whatever tag is already
committed in
versionconstants.go, exactly as today - a maintainerstill needs to push that exact tag via the existing (unchanged)
push-tagged-image.yml/push-tagged-dbimage.ymlbefore CI can pullit, same as before. Fork contributors still can't push to
ddev/*themselves; closing that gap is Phase 2.
Manual Testing Instructions
This is a build-tooling change more than a runtime one, so the most
direct way to see it work is documented in the two developer docs this
PR updates - read those first for the full explanation:
in
building-contributing.md- the new day-to-day flow.in
release-management.md- howmake print-image-tagsfeeds thestill-manual push step.
To exercise it yourself:
containers/ddev-webserver/(or another image directory).
makefrom the repository root.docker imagesshows a new localddev/ddev-webserver:<branch>-<hash>image, andgit diff pkg/versionconstants/versionconstants.goshows onlyWebTagchanged - no manual edit needed.makeagain with no further edits - confirm it's fast and doesnothing extra (hash already matches the committed tag, so there's
no Docker call at all).
ddev starton a test project and confirm it uses the localimage without attempting a pull.
make print-image-tagsand confirm the printed values matchwhat's committed.
containers/autotag_test.shdirectly to run the automated unittests for this logic in isolation.
Since this PR also bootstraps and pushes real images for the five
existing tags,
ddev start/CI against this branch as merged shouldalso work out of the box, pulling
ddev/ddev-webserver,ddev/ddev-webserver-prod,ddev/ddev-traefik-router,ddev/ddev-ssh-agent,ddev/ddev-xhgui, andddev/ddev-dbserver-mariadb-11.8at the tags now committed inpkg/versionconstants/versionconstants.go- all verified live andmulti-arch (
linux/amd64+linux/arm64) on Docker Hub.Automated Testing Overview
containers/autotag_test.shunit-testshash-paths.sh/autotag.shagainst a scratch git repository and a stubbed
docker(no realimage builds): determinism, dirty-tree/untracked-file sensitivity,
.gitignorehandling,--print-only, build-on-change, thelocal-image-already-exists dedup path, file-rewrite correctness
(including preserving trailing comments), and the central design
property that the unchanged/no-op path makes zero
dockercalls.Wired into
container-tests.ymlas a new standalone job on theexisting triggers - no new secrets or triggers added.
constants (
pkg/ddevapp/compose_yaml_test.go,cmd/ddev/cmd/cmd_version_test.go,pkg/dockerutil/docker_compose_test.go) read the constantsdynamically rather than asserting a hardcoded value, so they're
unaffected by the new tag format.
ddev start/ddev deletecycle against a scratch project using thefreshly built local image, and confirmed all six pushed images
resolve via
docker buildx imagetools inspectas live, multi-archimages under
ddev/*matching what's committed.Release/Deployment Notes
No CI or release workflow changes beyond the additive test job in
container-tests.yml. The existingpush-tagged-image.yml/push-tagged-dbimage.ymlworkflows are untouched and still require amaintainer to manually trigger them with a tag (now obtainable via
make print-image-tags) before a pushed image is available to pull.Forked-PR contributors still cannot push images themselves; that's
targeted by a planned follow-up (Phase 2).