Squashed '.ci/' changes from 80dabc2..aece7fc

aece7fc fix: Improve multi-arch manifest handling

git-subtree-dir: .ci
git-subtree-split: aece7fc1a4778a04f16313ae73c8f2b1e4c3a9fd
This commit is contained in:
Stefan Reimer 2022-11-14 14:12:04 +01:00
parent a3d88ec297
commit f2a07a275a

View File

@ -2,6 +2,7 @@
GTAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
TAG ?= $(shell echo $(GTAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//')
ARCH := amd64
ALL_ARCHS := amd64 arm64
# EXTRA_TAGS supposed to be set at the caller, eg. $(shell echo $(TAG) | awk -F '.' '{ print $$1 "." $$2 }')
@ -32,15 +33,17 @@ scan: ## Scan image using trivy
echo "Scanning $(REGISTRY)/$(IMAGE):$(TAG)-$(ARCH) using Trivy $(TRIVY_REMOTE)"
trivy image $(TRIVY_OPTS) $(REGISTRY)/$(IMAGE):$(TAG)-$(ARCH)
# We create new manifest and add TAG-ARCH image
# if manigest exists already, get it and add TAG-ARCH to eg. add arm64 to existing amd64
push: ## push images to registry
for t in $(TAG) latest $(EXTRA_TAGS); \
do echo "creating and pushing: $$t"; \
docker tag $(REGISTRY)/$(IMAGE):$(TAG)-$(ARCH) $(REGISTRY)/$(IMAGE):$${t}-$(ARCH) && \
docker push $(REGISTRY)/$(IMAGE):$${t}-$(ARCH); \
podman manifest exists $(IMAGE):$$t || podman manifest create $(IMAGE):$$t; \
buildah manifest add $(IMAGE):$$t $(REGISTRY)/$(IMAGE):$(TAG)-$(ARCH) && docker manifest push $(IMAGE):$$t $(REGISTRY)/$(IMAGE):$$t; \
# first tag and push all actual images
# create new manifest for each tag and add all available TAG-ARCH before pushing
push: ecr-login ## push images to registry
for t in $(TAG) latest $(EXTRA_TAGS); do \
[ "$$t" != "$(TAG)" ] && podman tag $(REGISTRY)/$(IMAGE):$(TAG)-$(ARCH) $(REGISTRY)/$(IMAGE):$${t}-$(ARCH); \
podman manifest exists $(IMAGE):$$t && podman manifest rm $(IMAGE):$$t; \
podman manifest create $(IMAGE):$$t; \
for a in $(ALL_ARCHS); do \
podman manifest add $(IMAGE):$$t $(REGISTRY)/$(IMAGE):$(TAG)-$$a; \
done; \
podman manifest push $(IMAGE):$$t $(REGISTRY)/$(IMAGE):$$t; \
done
ecr-login: ## log into AWS ECR public