diff --git a/Dockerfile b/Dockerfile index 51b4d9f..86f2b7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ -FROM registry.opensource.zalan.do/library/alpine-3.13:latest +ARG BASE_IMAGE=registry.opensource.zalan.do/library/alpine-3.13:latest +FROM ${BASE_IMAGE} LABEL maintainer="Team Teapot @ Zalando SE " RUN apk add --no-cache tzdata -# add binary -ADD build/linux/kube-metrics-adapter / +ARG TARGETARCH + +ADD build/linux/${TARGETARCH}/kube-metrics-adapter / ENTRYPOINT ["/kube-metrics-adapter"] diff --git a/Makefile b/Makefile index 911f4c1..0e69760 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,9 @@ $(OPENAPI): go.mod build.local: build/$(BINARY) $(GENERATED_CRDS) build.linux: build/linux/$(BINARY) -build.osx: build/osx/$(BINARY) +build.linux.amd64: build/linux/amd64/$(BINARY) +build.linux.arm64: build/linux/arm64/$(BINARY) + build/$(BINARY): go.mod $(SOURCES) $(GENERATED) CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" . @@ -58,11 +60,14 @@ build/$(BINARY): go.mod $(SOURCES) $(GENERATED) build/linux/$(BINARY): go.mod $(SOURCES) $(GENERATED) GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" . -build/osx/$(BINARY): go.mod $(SOURCES) $(GENERATED) - GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" . +build/linux/amd64/$(BINARY): go.mod $(SOURCES) + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/amd64/$(BINARY) -ldflags "$(LDFLAGS)" . + +build/linux/arm64/$(BINARY): go.mod $(SOURCES) + GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/arm64/$(BINARY) -ldflags "$(LDFLAGS)" . build.docker: build.linux - docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) . + docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) --build-arg TARGETARCH= . build.push: build.docker docker push "$(IMAGE):$(TAG)" diff --git a/delivery.yaml b/delivery.yaml index ec4dcb2..dea26ab 100644 --- a/delivery.yaml +++ b/delivery.yaml @@ -30,3 +30,17 @@ pipeline: IMAGE=$IMAGE VERSION=$VERSION make build.docker git diff --stat --exit-code IMAGE=$IMAGE VERSION=$VERSION make build.push + - desc: Build and push image to Zalando's registry + cmd: | + if [[ $CDP_TARGET_BRANCH == master && ! $CDP_PULL_REQUEST_NUMBER ]]; then + IMAGE=container-registry-test.zalando.net/teapot/kube-metrics-adapter + VERSION=$(git describe --tags --always) + else + IMAGE=container-registry-test.zalando.net/teapot/kube-metrics-adapter-test + VERSION=$CDP_BUILD_VERSION + fi + make build.linux.amd64 build.linux.arm64 + + docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use + docker buildx build --rm --build-arg BASE_IMAGE=container-registry.zalando.net/library/alpine-3.13:latest -t "${IMAGE}:${VERSION}" --platform linux/amd64,linux/arm64 --push . + cdp-promote-image "${IMAGE}:${VERSION}"