Skip to content

[Backport 0.11.x] Cross-compile go-discover instead of building it under QEMU - #410

Merged
suresh-hashicorp merged 1 commit into
release/0.11.xfrom
backport/cross-compile-go-discover-0.11.x
Nov 4, 2026
Merged

suresh-hashicorp merged 1 commit into
release/0.11.xfrom
backport/cross-compile-go-discover-0.11.x

Conversation

@suresh-hashicorp

Copy link
Copy Markdown
Contributor

Changes proposed in this PR:

  • Backport of Cross-compile go-discover instead of building it under QEMU #409 to release/0.11.x.
  • Pin the go-discover stage of the Dockerfile to $BUILDPLATFORM and cross-compile discover for the target platform (GOOS, GOARCH, and GOARM for 32-bit arm), instead of compiling it under QEMU emulation for arm and arm64.
  • A cross-compiled go install writes the binary to /go/bin/<os>_<arch>/, so it is moved to /go/bin/ and the final COPY --from=go-discover /go/bin/discover /bin/ is unchanged.
  • No CHANGELOG entry: this only changes how the image is built; the resulting binary and image contents are the same.

How I've tested this PR:

The cherry-pick applied cleanly with no changes. See #409 for the testing done: the go-discover stage built for linux/amd64, linux/arm64, linux/386, linux/arm/v6, linux/arm/v7 and linux/arm (architecture, GOARM and go-discover v1.5.0 checked with file and go version -m), and full release-default images for arm/v7 and arm64 where /bin/discover -h ran. CI results for this branch will be added once the checks finish.

Build time comparison:

Measured on #409 (this change on main): the slowest Docker job dropped from about 23.5 minutes (arm default, 1413s) to about 2.4 minutes (131s); arm64 default went from 701s to 136s and arm64 FIPS from 737s to 120s.

How I expect reviewers to test this PR:

  • Confirm the build workflow passes and the ARM Docker jobs take about 2-3 minutes.
  • Confirm CRT Artifact Validation Results passes after merge (artifact names don't change).

Checklist:

  • Tests added (not applicable, build change)
  • CHANGELOG entry added (not applicable, no user-facing change)

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request. (Revert the PR.)
  • If applicable, I've documented the impact of any changes to security controls. (None. The Go version and go-discover version are unchanged.)

Pin the go-discover stage to the build platform and cross-compile
discover for the target platform. This avoids compiling Go under QEMU
emulation for the arm and arm64 image builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@suresh-hashicorp
suresh-hashicorp requested review from a team as code owners October 30, 2026 07:51
@suresh-hashicorp
suresh-hashicorp deployed to dockerhub/hashicorpdev October 30, 2026 07:54 — with GitHub Actions Active
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.34%. Comparing base (2025d81) to head (3a9b761).

Additional details and impacted files
@@               Coverage Diff               @@
##           release/0.11.x     #410   +/-   ##
===============================================
  Coverage           59.34%   59.34%           
===============================================
  Files                  34       34           
  Lines                2890     2890           
===============================================
  Hits                 1715     1715           
  Misses                978      978           
  Partials              197      197           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the Dockerfile cross-compilation backport.

No open issues 🎉

What changed in this PR

Backports #409 to release/0.11.x, speeding up multi-platform image builds by cross-compiling go-discover on the build host instead of compiling under QEMU.

Changes:

  • Pins the go-discover stage to $BUILDPLATFORM.
  • Sets target OS, architecture, and ARM variant for cross-compilation.
  • Normalizes the binary output path, preserving the final image’s existing copy step and dependency versions.
File Description
Dockerfile Cross-compiles go-discover for the target platform and places the binary at the existing copy path.

Review effort: Balanced

@suresh-hashicorp
suresh-hashicorp merged commit ed72c8b into release/0.11.x Nov 4, 2026
39 checks passed
@suresh-hashicorp
suresh-hashicorp deleted the backport/cross-compile-go-discover-0.11.x branch November 4, 2026 05:45

This branch was successfully deployed

1 active deployment
dockerhub/hashicorpdev — 3a9b7610 Deployed Oct 30, 2026 by suresh-hashicorp via Upload dev image (hashicorpdev/consul-ecs:<commit>) (amd64) #1511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants