Skip to content

Use the existing docker-buildx Makefile target for cloudbuilds too instead of push-images python script#225

Open
creydr wants to merge 2 commits into
kubernetes-sigs:mainfrom
creydr:simplify-cloudbuild
Open

Use the existing docker-buildx Makefile target for cloudbuilds too instead of push-images python script#225
creydr wants to merge 2 commits into
kubernetes-sigs:mainfrom
creydr:simplify-cloudbuild

Conversation

@creydr
Copy link
Copy Markdown
Contributor

@creydr creydr commented Jun 3, 2026

Summary

The cloudbuild.yaml uses a Python script (dev/tools/push-images) to build and push multi-arch Docker images, duplicating logic already present in the Makefile's docker-buildx target.

This PR addresses it by reusing the existing Makefile target in the cloudbuild too.

Summary by CodeRabbit

  • Chores
    • Refactored container image build and tagging to support parameterized image names and multiple tags.
    • CI/build now invokes the unified make-based build step instead of the prior custom tooling.
    • Removed legacy build helper tooling and simplified shared build utilities.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for mcp-lifecycle-operator ready!

Name Link
🔨 Latest commit 0607964
🔍 Latest deploy log https://app.netlify.com/projects/mcp-lifecycle-operator/deploys/6a227a7c0056d90008bdde96
😎 Deploy Preview https://deploy-preview-225--mcp-lifecycle-operator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: creydr
Once this PR has been reviewed and has the lgtm label, please assign jaideepr97 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 3, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @creydr. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 3, 2026
…er-buildx target

The cloudbuild.yaml previously called a Python script (dev/tools/push-images)
to build and push multi-arch Docker images. The Makefile already had a
docker-buildx target doing essentially the same thing, so this consolidates
onto the Makefile target and removes the redundant Python code.

Changes:
- Add IMAGE_TAG_BASE, IMAGE_TAG, and GIT_IMAGE_TAG variables to the Makefile
  so IMG is derived from them and CI builds can reference GIT_IMAGE_TAG for
  date-and-commit based tags.
- Extend docker-buildx to support EXTRA_TAGS for applying additional tags
  in a single build.
- Simplify docker-buildx by removing the Dockerfile.cross sed workaround
  (the Dockerfile already handles TARGETOS/TARGETARCH natively).
- Update cloudbuild.yaml to call make docker-buildx directly.
- Delete dev/tools/push-images and dev/tools/shared/.
@creydr creydr force-pushed the simplify-cloudbuild branch from 7f590b3 to 6201af5 Compare June 5, 2026 06:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 99d43410-dba2-40d1-bedc-b9bc75e4faac

📥 Commits

Reviewing files that changed from the base of the PR and between 6201af5 and 0607964.

📒 Files selected for processing (1)
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile

📝 Walkthrough

Walkthrough

This PR migrates Docker image building from a Python CLI script to a Makefile-based docker-buildx approach. The Makefile now parameterizes image naming with configurable base name and tag variables, the docker-buildx target applies those variables plus any extra tags, and Cloud Build is updated to invoke the new Make command instead of the Python tool.

Changes

Image Build Toolchain Migration

Layer / File(s) Summary
Image naming parameterization and docker-buildx target
Makefile
Introduces IMAGE_TAG_BASE, IMAGE_TAG, and GIT_IMAGE_TAG variables to replace hardcoded image naming; updates IMG variable and docker-buildx target to use parameterized values and expand EXTRA_TAGS, and removes Dockerfile.cross reference from the build command.
Cloud Build step migration
cloudbuild.yaml
Replaces the python3 ./dev/tools/push-images invocation with make docker-buildx, passing image naming and extra tags as Make arguments constructed from Cloud Build substitutions.
Tool deprecation cleanup
dev/tools/shared/__init__.py
Clears the file header as part of deprecating the Python image-building tooling.

🎯 2 (Simple) | ⏱️ ~10 minutes

sequenceDiagram
  participant CloudBuild
  participant Makefile as Makefile/docker-buildx
  participant Buildx as Docker Buildx
  participant Registry as Image Registry
  CloudBuild->>Makefile: invoke `make docker-buildx` with IMAGE_TAG_BASE, IMAGE_TAG=$(GIT_IMAGE_TAG), EXTRA_TAGS
  Makefile->>Buildx: run `buildx build --push` tagging ${IMG} and $(IMAGE_TAG_BASE):$(tag)
  Buildx->>Registry: push image(s)
Loading

🐰 From Python scripts to Make targets we go,
Image tags now dance in variables' flow,
CloudBuild obeys the Makefile's command,
Simpler steps roll out across the land,
🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing a Python script with the existing Makefile docker-buildx target in cloudbuild.yaml, which is the core objective of this pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
Makefile (1)

11-11: ⚡ Quick win

Freeze GIT_IMAGE_TAG with := to avoid re-running $(shell ...)

Line 11 uses recursive expansion (=), so $(shell date ...) / $(shell git describe ...) are re-executed each time GIT_IMAGE_TAG is referenced. A simply-expanded assignment (:=) evaluates once and keeps the tag stable for the whole make run.

♻️ Proposed change
-GIT_IMAGE_TAG = v$(shell date +%Y%m%d)-$(shell git describe --always --dirty)
+GIT_IMAGE_TAG := v$(shell date +%Y%m%d)-$(shell git describe --always --dirty)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` at line 11, The Makefile currently defines GIT_IMAGE_TAG with
recursive expansion using "GIT_IMAGE_TAG = ...", causing the shell commands date
and git describe to run every time the variable is referenced; change the
assignment to a simply-expanded form "GIT_IMAGE_TAG :=" so the shell
substitutions (date and git describe) are evaluated once at assignment and the
image tag remains stable for the entire make invocation, updating the variable
definition for GIT_IMAGE_TAG accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Makefile`:
- Line 196: The docker-buildx invocation is prefixed with a dash so Make ignores
non-zero exits; edit the Makefile and remove the leading '-' before the
$(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG}
$(foreach tag,$(EXTRA_TAGS),-t $(IMAGE_TAG_BASE):$(tag)) . command (the
docker-buildx/buildx build --push invocation) so that a failed buildx push
returns a non-zero exit and fails the target/CI.

---

Nitpick comments:
In `@Makefile`:
- Line 11: The Makefile currently defines GIT_IMAGE_TAG with recursive expansion
using "GIT_IMAGE_TAG = ...", causing the shell commands date and git describe to
run every time the variable is referenced; change the assignment to a
simply-expanded form "GIT_IMAGE_TAG :=" so the shell substitutions (date and git
describe) are evaluated once at assignment and the image tag remains stable for
the entire make invocation, updating the variable definition for GIT_IMAGE_TAG
accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 017709b4-2acd-4ff8-b0a4-1378a2eeba2d

📥 Commits

Reviewing files that changed from the base of the PR and between 7214252 and 6201af5.

📒 Files selected for processing (5)
  • Makefile
  • cloudbuild.yaml
  • dev/tools/push-images
  • dev/tools/shared/__init__.py
  • dev/tools/shared/utils.py
💤 Files with no reviewable changes (3)
  • dev/tools/shared/init.py
  • dev/tools/shared/utils.py
  • dev/tools/push-images

Comment thread Makefile Outdated
Remove the leading dash from the buildx build command so a failed
build or push propagates as a non-zero exit code instead of being
silently ignored.
Comment thread Makefile
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
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.

@creydr maybe we want to add this into the Dockerfile itself?

My understanding here is this should improve our build times since go will natively cross compile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants