Skip to content

feat(containers): auto-detect content changes and tag/rebuild docker base images locally, for #8609 (#8612) [skip ci] - #8612

Merged
rfay merged 8 commits into
ddev:mainfrom
rfay:20260721_rfay_content_addressed_image_tags
Aug 14, 2026
Merged

rfay merged 8 commits into
ddev:mainfrom
rfay:20260721_rfay_content_addressed_image_tags

Conversation

@rfay

@rfay rfay commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

The Issue

TL;DR:

  1. make
  2. see what's changed in versionconstants.go. git diff rfay/20260721_rfay_content_addressed_image_tags pkg/versionconstants.go
  3. Push the updated version with [skip ci]
  4. Push the new image tags that changed
  5. Run tests with a new or amended commit.

Before, 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 a
human kept them in sync. Now: edit the image's files, run make, done.
make hashes the image's content, and if it changed, builds it locally
and 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/*/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 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

  • 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) 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, and deleted nightly_build.mak
    (confirmed unreferenced anywhere, and already broken with the same
    stale symbol names).
  • Bootstrapped all five image tags in this PR and pushed the
    corresponding images to ddev/* via the existing
    push-tagged-image.yml/push-tagged-dbimage.yml workflows, so
    pkg/versionconstants/versionconstants.go now points at real,
    live, multi-arch images rather than the old hand-typed strings.
  • Added containers/autotag_test.sh, a unit test for the hash/tag
    logic against a scratch git repo and a stubbed docker (no real
    builds), wired into .github/workflows/container-tests.yml as a
    small standalone job on the existing triggers.

CI is otherwise 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 just compiles 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.

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:

To exercise it yourself:

  1. Check out this branch and 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 - no manual edit needed.
  4. Run make again with no further edits - confirm it's fast and does
    nothing extra (hash already matches the committed tag, so there's
    no Docker call at all).
  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.
  7. Run containers/autotag_test.sh directly to run the automated unit
    tests 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 should
also work out of the box, pulling ddev/ddev-webserver,
ddev/ddev-webserver-prod, ddev/ddev-traefik-router,
ddev/ddev-ssh-agent, ddev/ddev-xhgui, and
ddev/ddev-dbserver-mariadb-11.8 at the tags now committed in
pkg/versionconstants/versionconstants.go - all verified live and
multi-arch (linux/amd64 + linux/arm64) on Docker Hub.

Automated Testing Overview

  • containers/autotag_test.sh unit-tests hash-paths.sh/autotag.sh
    against a scratch git repository and a stubbed docker (no real
    image builds): determinism, dirty-tree/untracked-file sensitivity,
    .gitignore handling, --print-only, build-on-change, the
    local-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 docker calls.
    Wired into container-tests.yml as a new standalone job on the
    existing triggers - no new secrets or triggers added.
  • No new Go tests were added; 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 using the
    freshly built local image, and confirmed all six pushed images
    resolve via docker buildx imagetools inspect as live, multi-arch
    images 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 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).

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file enhancement labels Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

@rfay rfay changed the title feat(containers): auto-detect content changes and tag/rebuild images locally, for #8609 feat(containers): auto-detect content changes and tag/rebuild docker base images locally, for #8609 Jul 25, 2026
@rfay
rfay requested a review from stasadev July 25, 2026 13:21
@rfay
rfay marked this pull request as ready for review July 25, 2026 13:21
@rfay
rfay requested review from a team as code owners July 25, 2026 13:21
@rfay
rfay force-pushed the 20260721_rfay_content_addressed_image_tags branch from 192c0fd to 497cd08 Compare July 29, 2026 00:50
@rfay

rfay commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

Rebased. Updated webimage hash (new here). Improved docs so the TL;DR shows, it may still need work.
Updating the image hash is just make but if there's a change, the new image has to be manually pushed where this stands right now.

@rfay
rfay force-pushed the 20260721_rfay_content_addressed_image_tags branch 3 times, most recently from 040fa43 to 17d199e Compare July 29, 2026 22:32

@stasadev stasadev left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like it, but how do we push new images for a release?

I ran make, it created new images locally, and now I want to use v1.25.4 inside the versionconstants.go, but make reverts them back.

@rfay

rfay commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

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.

@rfay
rfay force-pushed the 20260721_rfay_content_addressed_image_tags branch 2 times, most recently from 26b8f07 to 2ce449b Compare August 11, 2026 22:14
@rfay

rfay commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Rebased. Updated the TL;DR to explain what has to be done (and what I just did for the rebase)

@rfay
rfay requested a review from stasadev August 11, 2026 22:19
rfay and others added 7 commits August 13, 2026 20:55
…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
@rfay
rfay force-pushed the 20260721_rfay_content_addressed_image_tags branch 2 times, most recently from d1dca98 to 2a44c20 Compare August 14, 2026 02:58
@rfay
rfay force-pushed the 20260721_rfay_content_addressed_image_tags branch from 2a44c20 to 2c3f845 Compare August 14, 2026 03:14

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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"

@rfay

rfay commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

I changed it like this, ran make autotag-images, and it didn't detect any changes:

The first part of the tag name is ignored, it's only there for human reading, but the auto-tag uses only the hash.

@rfay rfay changed the title feat(containers): auto-detect content changes and tag/rebuild docker base images locally, for #8609 feat(containers): auto-detect content changes and tag/rebuild docker base images locally, for #8609 (#8612) [skip ci] Aug 14, 2026
@rfay
rfay merged commit f08ee24 into ddev:main Aug 14, 2026
50 of 51 checks passed
@rfay
rfay deleted the 20260721_rfay_content_addressed_image_tags branch August 14, 2026 18:12
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 14, 2026
…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
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 14, 2026
…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
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 14, 2026
…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
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 16, 2026
…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
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 16, 2026
…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]>
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 17, 2026
…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
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 17, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants