From a34fa20532201b9aee0371a6ec007926f5c048df Mon Sep 17 00:00:00 2001 From: Tim Usner Date: Tue, 5 Jul 2022 15:24:44 +0200 Subject: [PATCH 1/2] Build DWD in Docker container --- .ci/build | 22 +++++----------------- Makefile | 1 - build/Dockerfile | 9 ++++++++- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.ci/build b/.ci/build index f9db0f61..f5f8542a 100755 --- a/.ci/build +++ b/.ci/build @@ -55,21 +55,9 @@ VERSION_FILE="$(${READLINK_BIN} -f "${SOURCE_PATH}/VERSION")" VERSION="$(cat "${VERSION_FILE}")" GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound") -# If no LOCAL_BUILD environment variable is set, we configure the `go build` command -# to build for linux OS, amd64 architectures and without CGO enablement. -if [[ -z "$LOCAL_BUILD" ]]; then - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build \ - -a \ - -mod vendor \ - -v \ - -o "${BINARY_PATH}/linux-amd64/dependency-watchdog" \ - main.go +CGO_ENABLED=0 GO111MODULE=on go build \ + -mod vendor \ + -v \ + -o "${BINARY_PATH}/dependency-watchdog" \ + main.go -# If the LOCAL_BUILD environment variable is set, we simply run `go build`. -else - GO111MODULE=on go build \ - -mod vendor \ - -v \ - -o "${BINARY_PATH}/dependency-watchdog" \ - main.go -fi diff --git a/Makefile b/Makefile index d0ece196..2e492ef6 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,6 @@ build-local: .PHONY: docker-image docker-image: - @if [[ ! -f $(BIN_DIR)/linux-amd64/dependency-watchdog ]]; then echo "No binary found. Please run 'make build'"; false; fi @docker build -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) -f $(BUILD_DIR)/Dockerfile --rm . .PHONY: docker-push diff --git a/build/Dockerfile b/build/Dockerfile index 1a1c8069..5d98e355 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -2,10 +2,17 @@ # # SPDX-License-Identifier: Apache-2.0 +From golang:1.18.3 as builder + +WORKDIR /go/src/github.com/gardener/dependency-watchdog +COPY . . + +RUN make build + FROM alpine:3.15.4 RUN apk add --update bash curl -COPY ./bin/linux-amd64/dependency-watchdog /usr/local/bin/dependency-watchdog +COPY --from=builder /go/src/github.com/gardener/dependency-watchdog/bin/dependency-watchdog /usr/local/bin/dependency-watchdog WORKDIR / ENTRYPOINT ["/usr/local/bin/dependency-watchdog"] From 7276792d4ca77a887ef6756b066b9c4996df5767 Mon Sep 17 00:00:00 2001 From: Tim Usner Date: Tue, 5 Jul 2022 15:25:01 +0200 Subject: [PATCH 2/2] Let pipeline build multi-arch images --- .ci/pipeline_definitions | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ci/pipeline_definitions b/.ci/pipeline_definitions index 8cc57b33..90b739f4 100644 --- a/.ci/pipeline_definitions +++ b/.ci/pipeline_definitions @@ -11,6 +11,10 @@ dependency-watchdog: 'inject-commit-hash' inject_effective_version: true publish: + oci-builder: docker-buildx + platforms: + - linux/amd64 + - linux/arm64 dockerimages: dependency-watchdog: registry: 'gcr-readwrite'