# Makefile for building our Docker containers | |
# | |
# You can override ARCH and REGISTRY, the default to "amd64 arm arm64 ppc64le s390x" and "miek" | |
# If you need to get an asset before building use the asset rule. The asset needs to be copied | |
# to $(arch): | |
# | |
# asset: | |
# cp $(COREDNS)/coredns $(arch)/coredns | |
ifeq (, $(shell which manifest-tool)) | |
$(error No manifest-tool in $$PATH, install with: "go get github.com/estesp/manifest-tool") | |
endif | |
# Limit architectures we push, full list is: amd64 arm arm64 ppc64le s390x | |
REGISTRY:=miek | |
ifeq ($(ARCH),) | |
$(error Please specify architectures use. Full list is "amd64 arm arm64 ppc64le s390x") | |
endif | |
DIR:=$(shell basename $$PWD) | |
IMAGE=$(REGISTRY)/$(DIR) | |
EMPTY:= | |
SPACE:=$(EMPTY) $(EMPTY) | |
COMMA:=$(EMPTY),$(EMPTY) | |
PLATFORMS:=$(subst $(SPACE),$(COMMA),$(foreach arch,$(ARCH),linux/$(arch))) | |
.PHONY: build | |
build: | |
for a in $(ARCH); do \ | |
mkdir -p $$a ;\ | |
cp * $$a 2>/dev/null ;\ | |
make arch=$$a asset ;\ | |
../../bin/dockerfile $$a > $$a/Dockerfile ;\ | |
docker build -t $(IMAGE):$(VERSION) $$a && \ | |
rm -rf $$a ;\ | |
docker tag $(IMAGE):$(VERSION) $(IMAGE)-$$a ;\ | |
docker tag $(IMAGE):$(VERSION) $(IMAGE):latest ;\ | |
done | |
.PHONY: push | |
push: | |
for a in $(ARCH); do \ | |
docker push $(IMAGE)-$$a ;\ | |
done | |
manifest-tool push from-args --platforms $(PLATFORMS) --template $(IMAGE)-ARCH --target $(IMAGE):$(VERSION) | |
manifest-tool push from-args --platforms $(PLATFORMS) --template $(IMAGE)-ARCH --target $(IMAGE):latest | |
.PHONY: clean | |
clean: | |
rm -rf $(ARCH) | |
.PHONY: asset | |
asset: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment