Build multi-arch container images across stack
diff --git a/apps/bwolf-gandi/.gitignore b/apps/bwolf-gandi/.gitignore
index fcff3af..b90f1c2 100644
--- a/apps/bwolf-gandi/.gitignore
+++ b/apps/bwolf-gandi/.gitignore
@@ -1,2 +1,3 @@
cert-manager-webhook-gandi
-webhook
+webhook_arm64
+webhook_amd64
diff --git a/apps/bwolf-gandi/Dockerfile b/apps/bwolf-gandi/Dockerfile
index 6fee6aa..df46fc1 100644
--- a/apps/bwolf-gandi/Dockerfile
+++ b/apps/bwolf-gandi/Dockerfile
@@ -1,8 +1,10 @@
FROM alpine:3.9
+ARG TARGETARCH
+
RUN apk add --no-cache ca-certificates
-COPY webhook /usr/local/bin/webhook
+COPY webhook_${TARGETARCH} /usr/local/bin/webhook
RUN chmod +x /usr/local/bin/webhook
ENTRYPOINT ["webhook"]
diff --git a/apps/bwolf-gandi/Makefile b/apps/bwolf-gandi/Makefile
index cdfc936..2a09874 100644
--- a/apps/bwolf-gandi/Makefile
+++ b/apps/bwolf-gandi/Makefile
@@ -2,23 +2,26 @@
IMAGE_TAG := "v0.2.0"
checkout:
- git clone --depth 1 --branch v0.2.0 https://github.com/bwolf/cert-manager-webhook-gandi.git
+ git clone --depth 1 --branch $(IMAGE_TAG) https://github.com/bwolf/cert-manager-webhook-gandi.git
clean:
- rm -f webhook
+ rm -f webhook_*
-build: export CGO_ENABLED=0
-build: export GO111MODULE=on
-build: clean
- cd cert-manager-webhook-gandi && go build -o ../webhook -ldflags '-w -extldflags "-static"' .
+build_arm64: export CGO_ENABLED=0
+build_arm64: export GO111MODULE=on
+build_arm64: export GOOS=linux
+build_arm64: export GOARCH=arm64
+build_arm64: clean
+ cd cert-manager-webhook-gandi && go build -o ../webhook_arm64 -ldflags '-w -extldflags "-static"' .
-image: build
- docker build --tag=$(IMAGE_NAME):$(IMAGE_TAG) . --platform=linux/arm64
+build_amd64: export CGO_ENABLED=0
+build_amd64: export GO111MODULE=on
+build_amd64: export GOOS=linux
+build_amd64: export GOARCH=amd64
+build_amd64: clean
+ cd cert-manager-webhook-gandi && go build -o ../webhook_amd64 -ldflags '-w -extldflags "-static"' .
-push: image
- docker push $(IMAGE_NAME):$(IMAGE_TAG)
+build: clean build_arm64 build_amd64
-
-push_arm64: export GOOS=linux
-push_arm64: export GOARCH=arm64
-push_arm64: push
+push: build
+ docker buildx build --tag=$(IMAGE_NAME):$(IMAGE_TAG) . --platform=linux/arm64,linux/amd64 --push