ipabusedb-docker-reporter: build and push multi-arch image

make push builds linux/amd64 and linux/arm64 natively, each on a daemon
of that arch (amd64 on fsn1app1 via DOCKER_HOST, arm64 locally), pushes
the per-arch tags, and joins them into the dated and latest manifest
lists with docker buildx imagetools, mirroring the baseimage repo.
This commit is contained in:
sneak committed 2026-11-06 20:37:00 -08:00
1 parent bce9d01142
commit ea0c484370
2 files changed
+36 -10

No files matched your search

+27 -5
View File
@@ -2,17 +2,39 @@ BIN := ipabusedb-docker-reporter
IMAGE := git.eeqj.de/sneak/$(BIN)
TAG := $(shell date -u +%Y-%m-%d)
.PHONY: build test lint fmt fmt-check check clean image push
# Each arch is built natively on a daemon of that arch: arm64 on the local
# daemon, amd64 on fsn1app1. Override on the command line if needed.
ARCHES := amd64 arm64
DOCKER_HOST_amd64 ?= ssh://root@fsn1app1
DOCKER_HOST_arm64 ?=
docker_for = $(if $(DOCKER_HOST_$(1)),DOCKER_HOST=$(DOCKER_HOST_$(1))) docker
.PHONY: build test lint fmt fmt-check check clean image push manifest \
$(ARCHES:%=image-%) $(ARCHES:%=push-%)
build:
go build -o $(BIN) .
# Local image for this machine's arch, for testing.
image:
docker build -t $(BIN) -t $(IMAGE):$(TAG) -t $(IMAGE):latest .
docker build -t $(BIN) .
push: image
docker push $(IMAGE):$(TAG)
docker push $(IMAGE):latest
# image-ARCH builds on that arch's daemon; push-ARCH pushes the arch tag.
define arch_rules
image-$(1):
$$(call docker_for,$(1)) build --platform linux/$(1) -t $$(IMAGE):$(1) .
push-$(1): image-$(1)
$$(call docker_for,$(1)) push $$(IMAGE):$(1)
endef
$(foreach a,$(ARCHES),$(eval $(call arch_rules,$(a))))
# Join the per-arch tags into the dated and latest multi-arch manifests.
manifest:
docker buildx imagetools create -t $(IMAGE):$(TAG) -t $(IMAGE):latest \
$(ARCHES:%=$(IMAGE):%)
push: $(ARCHES:%=push-%) manifest
test:
go test ./...