From b4fd5bf415429ef41a4fbbd9c0b3c7a49da10474 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Thu, 28 Dec 2023 14:57:02 -0700 Subject: [PATCH] CI: Build auto-pause-hook for all architectures --- Makefile | 8 +++++--- deploy/addons/auto-pause/Dockerfile | 11 +++++++++-- hack/update/golang_version/update_golang_version.go | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c3f250e1c167..8fe8e09d1e8d 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ SHA512SUM=$(shell command -v sha512sum || echo "shasum -a 512") GVISOR_TAG ?= latest # auto-pause-hook tag to push changes to -AUTOPAUSE_HOOK_TAG ?= v0.0.4 +AUTOPAUSE_HOOK_TAG ?= v0.0.5 # prow-test tag to push changes to PROW_TEST_TAG ?= v0.0.5 @@ -959,9 +959,11 @@ auto-pause-hook-image: deploy/addons/auto-pause/auto-pause-hook ## Build docker docker build -t $(REGISTRY)/auto-pause-hook:$(AUTOPAUSE_HOOK_TAG) ./deploy/addons/auto-pause .PHONY: push-auto-pause-hook-image -push-auto-pause-hook-image: auto-pause-hook-image +push-auto-pause-hook-image: docker-multi-arch-build docker login gcr.io/k8s-minikube - $(MAKE) push-docker IMAGE=$(REGISTRY)/auto-pause-hook:$(AUTOPAUSE_HOOK_TAG) + docker buildx create --name multiarch --bootstrap + docker buildx build --push --builder multiarch --platform $(KICBASE_ARCH) -t $(REGISTRY)/auto-pause-hook:$(AUTOPAUSE_HOOK_TAG) -f ./deploy/addons/auto-pause/Dockerfile . + docker buildx rm multiarch .PHONY: push-prow-test-image push-prow-test-image: docker-multi-arch-build diff --git a/deploy/addons/auto-pause/Dockerfile b/deploy/addons/auto-pause/Dockerfile index 176bcd7ec8e4..7f2b6b2bdfaa 100644 --- a/deploy/addons/auto-pause/Dockerfile +++ b/deploy/addons/auto-pause/Dockerfile @@ -1,2 +1,9 @@ -FROM golang:1.21.5 -ADD auto-pause-hook /auto-pause-hook +FROM golang:1.21.5 AS builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY ./ ./ +RUN GOOS=linux CGO_ENABLED=0 go build -a --ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo -o auto-pause-hook cmd/auto-pause/auto-pause-hook/main.go cmd/auto-pause/auto-pause-hook/config.go cmd/auto-pause/auto-pause-hook/certs.go + +FROM scratch +COPY --from=builder /app/auto-pause-hook /auto-pause-hook diff --git a/hack/update/golang_version/update_golang_version.go b/hack/update/golang_version/update_golang_version.go index a01874894605..bbdce249dc8d 100644 --- a/hack/update/golang_version/update_golang_version.go +++ b/hack/update/golang_version/update_golang_version.go @@ -67,7 +67,7 @@ var ( }, "deploy/addons/auto-pause/Dockerfile": { Replace: map[string]string{ - `golang:.*`: `golang:{{.StableVersion}}`, + `golang:.* AS`: `golang:{{.StableVersion}} AS`, }, }, }