aboutsummaryrefslogtreecommitdiff
path: root/Makefile.release
diff options
context:
space:
mode:
authorGravatar Manuel Rüger <manuel@rueg.eu> 2021-01-28 19:11:38 +0100
committerGravatar GitHub <noreply@github.com> 2021-01-28 19:11:38 +0100
commit028f0eb33178612a14bba14b95040f4831f363d9 (patch)
treebb3251b73417dfe82d1190836173bfa1331dd194 /Makefile.release
parent60e1490ed6c37991ec470cecb30615123ecbee05 (diff)
downloadcoredns-028f0eb33178612a14bba14b95040f4831f363d9.tar.gz
coredns-028f0eb33178612a14bba14b95040f4831f363d9.tar.zst
coredns-028f0eb33178612a14bba14b95040f4831f363d9.zip
Makefile.release: Replace manifest-tool with docker manifest (#4421)
This commit replaces `manifest-tool` with `docker manifest`, which should hopefully provide a better experience for releasing coredns. In addition it integrates mips64le (since it's supported by `docker manifest`) in LINUX_ARCHES, so docker images for mips64le are pushed as well. Signed-off-by: Manuel Rüger <manuel@rueg.eu>
Diffstat (limited to 'Makefile.release')
-rw-r--r--Makefile.release41
1 files changed, 25 insertions, 16 deletions
diff --git a/Makefile.release b/Makefile.release
index 129b0da17..b6432c7f7 100644
--- a/Makefile.release
+++ b/Makefile.release
@@ -44,20 +44,17 @@ EMPTY:=
SPACE:=$(EMPTY) $(EMPTY)
COMMA:=$(EMPTY),$(EMPTY)
-ifeq (, $(shell which curl))
+ifeq (, $(shell command -v curl))
$(error "No curl in $$PATH, please install")
endif
-ifeq (, $(shell which manifest-tool))
- $(error "No manifest-tool in $$PATH, please install")
-endif
DOCKER:=
NAME:=coredns
VERSION:=$(shell grep 'CoreVersion' coremain/version.go | awk '{ print $$3 }' | tr -d '"')
GITHUB:=coredns
DOCKER_IMAGE_NAME:=$(DOCKER)/$(NAME)
-# mips is not in LINUX_ARCH because it's not supported by the manifest-tool.
-LINUX_ARCH:=amd64 arm arm64 ppc64le s390x
+# mips is not in LINUX_ARCH because it's not supported by docker manifest
+LINUX_ARCH:=amd64 arm arm64 mips64le ppc64le s390x
PLATFORMS:=$(subst $(SPACE),$(COMMA),$(foreach arch,$(LINUX_ARCH),linux/$(arch)))
all:
@@ -77,8 +74,6 @@ build:
mkdir -p build/windows/amd64 && $(MAKE) coredns BINARY=build/windows/amd64/$(NAME).exe SYSTEM="GOOS=windows GOARCH=amd64" CHECKS="" BUILDOPTS=""
@echo Building: linux/mips - $(VERSION)
mkdir -p build/linux/mips && $(MAKE) coredns BINARY=build/linux/mips/$(NAME) SYSTEM="GOOS=linux GOARCH=mips" CHECKS="" BUILDOPTS=""
- @echo Building: linux/mips64le - $(VERSION)
- mkdir -p build/linux/mips64le && $(MAKE) coredns BINARY=build/linux/mips64le/$(NAME) SYSTEM="GOOS=linux GOARCH=mips64le" CHECKS="" BUILDOPTS=""
@echo Building: linux/$(LINUX_ARCH) - $(VERSION) ;\
for arch in $(LINUX_ARCH); do \
mkdir -p build/linux/$$arch && $(MAKE) coredns BINARY=build/linux/$$arch/$(NAME) SYSTEM="GOOS=linux GOARCH=$$arch" CHECKS="" BUILDOPTS="" ;\
@@ -135,11 +130,11 @@ else
@# 2. Copy Dockerfile to build/docker/linux/<arch>
@rm -rf build/docker
for arch in $(LINUX_ARCH); do \
- mkdir -p build/docker/linux/$$arch ;\
- tar -xzf release/$(NAME)_$(VERSION)_linux_$$arch.tgz -C build/docker/linux/$$arch ;\
- cp Dockerfile build/docker/linux/$$arch ;\
- docker build -t coredns build/docker/linux/$$arch ;\
- docker tag coredns $(DOCKER_IMAGE_NAME):coredns-$$arch ;\
+ mkdir -p build/docker/linux/$${arch} ;\
+ tar -xzf release/$(NAME)_$(VERSION)_linux_$${arch}.tgz -C build/docker/linux/$${arch} ;\
+ cp Dockerfile build/docker/linux/$${arch} ;\
+ docker build -t $(DOCKER_IMAGE_NAME)-$${arch}:$(VERSION) build/docker/linux/$${arch} ;\
+ docker tag $(DOCKER_IMAGE_NAME)-$${arch}:$(VERSION) $(DOCKER_IMAGE_NAME)-$${arch}:latest ;\
done
endif
@@ -148,13 +143,27 @@ docker-push:
ifeq ($(DOCKER),)
$(error "Please specify Docker registry to use. Use DOCKER=coredns for releases")
else
+ @# Experimental CLI is required for docker manifest to work
+ @# Pushes coredns/coredns-$arch:$version images
+ @# Creates manifest for multi-arch image
+ @# Pushes multi-arch image to coredns/coredns:$version
+ export DOCKER_CLI_EXPERIMENTAL=enabled
@echo $(DOCKER_PASSWORD) | docker login -u $(DOCKER_LOGIN) --password-stdin
@echo Pushing: $(VERSION) to $(DOCKER_IMAGE_NAME)
for arch in $(LINUX_ARCH); do \
- docker push $(DOCKER_IMAGE_NAME):coredns-$$arch ;\
+ docker push $(DOCKER_IMAGE_NAME)-$${arch}:$(VERSION) ;\
+ docker push $(DOCKER_IMAGE_NAME)-$${arch}:latest ;\
+ done
+ DOCKER_IMAGE_LIST_VERSIONED:=$(shell echo $(LINUX_ARCH) | sed -e "s~[^ ]*~$(DOCKER_IMAGE_NAME)\-&:$(VERSION)~g")
+ DOCKER_IMAGE_LIST_LATEST:=$(shell echo $(LINUX_ARCH) | sed -e "s~[^ ]*~$(DOCKER_IMAGE_NAME)\-&:latest~g")
+ docker manifest create --amend $(DOCKER_IMAGE_NAME):$(VERSION) $(DOCKER_IMAGE_LIST_VERSIONED)
+ docker manifest create --amend $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_LIST_LATEST)
+ for arch in $(LINUX_ARCH); do \
+ docker manifest annotate --arch $${arch} $(DOCKER_IMAGE_NAME):$(VERSION) $(DOCKER_IMAGE_NAME)-$${arch}:$(VERSION) ;\
+ docker manifest annotate --arch $${arch} $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME)-$${arch}:latest ;\
done
- manifest-tool push from-args --platforms $(PLATFORMS) --template $(DOCKER_IMAGE_NAME):coredns-ARCH --target $(DOCKER_IMAGE_NAME):$(VERSION)
- manifest-tool push from-args --platforms $(PLATFORMS) --template $(DOCKER_IMAGE_NAME):coredns-ARCH --target $(DOCKER_IMAGE_NAME):latest
+ docker manifest push --purge $(DOCKER_IMAGE_NAME):$(VERSION)
+ docker manifest push --purge $(DOCKER_IMAGE_NAME):latest
endif
.PHONY: version