mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2024-12-22 11:06:04 +00:00
Merge pull request #448 from zalando-incubator/multi-arch-image
Build multi-arch image
This commit is contained in:
commit
37969486fe
@ -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 <team-teapot@zalando.de>"
|
||||
|
||||
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"]
|
||||
|
13
Makefile
13
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)"
|
||||
|
@ -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}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user