refactor(vermeer): cross-compile Docker binaries#353
Conversation
- pin the Go builder to the native build platform - cross-compile binaries for each requested target platform - cache Go modules and compiler artifacts across builds - isolate UI dependency downloads from source changes
There was a problem hiding this comment.
Pull request overview
This PR updates Vermeer’s Docker build to avoid QEMU-based cross-builds by running the Go builder stage on the native BuildKit platform and cross-compiling a CGO-disabled target binary using TARGETOS/TARGETARCH. It also improves build performance by adding BuildKit cache mounts and restructuring COPY steps to maximize layer cache hits.
Changes:
- Run the builder stage on
$BUILDPLATFORMand cross-compile the final binary withGOOS=$TARGETOSandGOARCH=$TARGETARCH(withCGO_ENABLED=0). - Add BuildKit cache mounts for Go module downloads and Go compiler build cache.
- Reorder
COPYsteps to separate dependency downloads (Go modules + UI assets) from the full source copy for better caching.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
✅ Review summary
Note
Cross-compilation is correct, but target-specific arguments currently prevent BuildKit from sharing otherwise target-neutral setup layers.
🧪 How this was verified
| Independent check | What it traced | Outcome |
|---|---|---|
| 🏗️ Multi-platform semantics | Followed BUILDPLATFORM, TARGETOS/TARGETARCH, the CGO_ENABLED=0 build, and the target-specific Alpine final stage. |
No wrong-architecture binary or runtime-stage defect was found. |
| 📦 Dependency and UI cache path | Traced go.mod/go.sum, download_ui_assets.sh, ui/package.json, go generate, and the reordered COPY layers. |
Confirmed that target arguments are in scope before target-neutral downloads and asset generation, so those layers cannot be shared across target platforms. |
| 🧾 Real Buildx execution | Inspected the amd64/arm64 validation run. | Both images built successfully, while BuildKit logs showed the neutral setup repeated as paired steps 14–15, 20–21, 26–27, and 30–31; this is the evidence behind the inline finding. |
🤖 Codex review · GPT-5.6 Sol · effort: max
- keep target-neutral preparation cacheable across platforms - expose target OS and architecture only to final compilation - preserve native builder cross-compilation behavior
There was a problem hiding this comment.
✅ Review summary
Note
The Dockerfile correctly cross-compiles Vermeer for the supported Buildx amd64 and arm64 targets without an actionable regression.
🧪 Verification matrix
| Independent check | What it traced | Outcome |
|---|---|---|
| ✅ Cross-platform build semantics Clear |
BUILDPLATFORM, TARGETOS, TARGETARCH, CGO settings, final Alpine runtime stage | The reviewer confirmed that the builder runs on the build platform while the Go binary is compiled for the requested amd64 or arm64 target and copied into the matching runtime image. |
| ✅ Dependency and UI preparation Clear |
go.mod and go.sum caching, download_ui_assets.sh, asset/vfsgen.go, .dockerignore and COPY ordering | The reviewer confirmed that the reordered Docker layers preserve every dependency, generated UI asset, and embedded-resource input required by the final build. |
| 🧹 Downstream build compatibility Dropped |
repository Docker workflows, build_docker.sh, documented image build commands, Buildx requirements | The reviewer raised a legacy-builder concern, but the lead review dropped it because repository and release workflows explicitly use Buildx and document no legacy Docker builder contract. |
| 🟡 Multi-platform execution evidence Limited |
external run 29188192310, current-head run 29195060984, local Docker and Go availability | The external validation built both GOARCH=amd64 and GOARCH=arm64 at f5bd393, while current-head execution remained limited because the workflow failed before creating jobs and local build tools were unavailable. |
Warning
Verification limits
- The current head could not be built locally because the Docker daemon is stopped and the Go toolchain is not installed.
- The current-head Vermeer CI run ended in startup_failure before creating jobs.
🤖 Codex review · GPT-5.6 Sol · effort: xhigh
Summary
Measured validation
Companion cache and branch-validation workflow: hugegraph/actions#22.
Verification