File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ # Pin the builder stage to the build host's native arch ($BUILDPLATFORM) and
16+ # cross-compile to the requested $TARGETARCH with Go's own toolchain, rather
17+ # than running an emulated (QEMU) builder for foreign platforms. Multi-arch
18+ # GB200 UAT builds (linux/amd64,linux/arm64 on an amd64 runner) previously
19+ # executed the arm64 `go build` under emulation (~15 min); cross-compiling on
20+ # the native builder brings it back to native speed. The final distroless stage
21+ # is a COPY-only layer, so it needs no emulation for the target arch.
1522ARG GO_VERSION=1.26.3
16- FROM golang:${GO_VERSION}-bookworm AS builder
23+ FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS builder
1724
1825WORKDIR /src
1926COPY go.mod go.sum ./
@@ -22,7 +29,8 @@ COPY pkg/ pkg/
2229COPY validators/ validators/
2330COPY recipes/ recipes/
2431
25- RUN CGO_ENABLED=0 go build -o /out/conformance ./validators/conformance
32+ ARG TARGETOS TARGETARCH
33+ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/conformance ./validators/conformance
2634
2735FROM nvcr.io/nvidia/distroless/static:v4.0.0@sha256:d90158b69e250d2018f32622b5c622925202ee97224a990a54b63811cb1e3d69
2836
Original file line number Diff line number Diff line change 2020# v1alpha1.Test AST and dispatches assert/error to kyverno-json's
2121# checks.Check engine, so the external binary is no longer needed.
2222
23+ # Pin the builder stage to the build host's native arch ($BUILDPLATFORM) and
24+ # cross-compile to the requested $TARGETARCH with Go's own toolchain, rather
25+ # than running an emulated (QEMU) builder for foreign platforms. Multi-arch
26+ # GB200 UAT builds (linux/amd64,linux/arm64 on an amd64 runner) previously
27+ # executed the arm64 `go build` under emulation (~15 min); cross-compiling on
28+ # the native builder brings it back to native speed. The final distroless stage
29+ # is a COPY-only layer, so it needs no emulation for the target arch.
2330ARG GO_VERSION=1.26.3
24- FROM golang:${GO_VERSION}-bookworm AS builder
31+ FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS builder
2532
2633WORKDIR /src
2734COPY go.mod go.sum ./
@@ -30,7 +37,8 @@ COPY pkg/ pkg/
3037COPY recipes/ recipes/
3138COPY validators/ validators/
3239
33- RUN CGO_ENABLED=0 go build -o /out/deployment ./validators/deployment
40+ ARG TARGETOS TARGETARCH
41+ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/deployment ./validators/deployment
3442
3543FROM nvcr.io/nvidia/distroless/static:v4.0.0@sha256:d90158b69e250d2018f32622b5c622925202ee97224a990a54b63811cb1e3d69
3644
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ # Pin the builder stage to the build host's native arch ($BUILDPLATFORM) and
16+ # cross-compile to the requested $TARGETARCH with Go's own toolchain, rather
17+ # than running an emulated (QEMU) builder for foreign platforms. Multi-arch
18+ # GB200 UAT builds (linux/amd64,linux/arm64 on an amd64 runner) previously
19+ # executed the arm64 `go build` under emulation (~15 min); cross-compiling on
20+ # the native builder brings it back to native speed. The final distroless stage
21+ # is a COPY-only layer, so it needs no emulation for the target arch.
1522ARG GO_VERSION=1.26.3
16- FROM golang:${GO_VERSION}-bookworm AS builder
23+ FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS builder
1724
1825WORKDIR /src
1926COPY go.mod go.sum ./
@@ -22,7 +29,8 @@ COPY pkg/ pkg/
2229COPY validators/ validators/
2330COPY recipes/ recipes/
2431
25- RUN CGO_ENABLED=0 go build -o /out/performance ./validators/performance
32+ ARG TARGETOS TARGETARCH
33+ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/performance ./validators/performance
2634
2735FROM nvcr.io/nvidia/distroless/static:v4.0.0@sha256:d90158b69e250d2018f32622b5c622925202ee97224a990a54b63811cb1e3d69
2836
You can’t perform that action at this time.
0 commit comments