Build multi-arch container images across stack
diff --git a/core/auth/hydra-maester/Dockerfile b/core/auth/hydra-maester/Dockerfile
index 072d9b2..585f9af 100644
--- a/core/auth/hydra-maester/Dockerfile
+++ b/core/auth/hydra-maester/Dockerfile
@@ -1,4 +1,5 @@
 FROM gcr.io/distroless/static:latest
-COPY hydra-maester/manager .
+ARG TARGETARCH
+COPY hydra-maester/manager_${TARGETARCH} /manager
 USER 1000
 ENTRYPOINT ["/manager"]
diff --git a/core/auth/hydra-maester/Makefile b/core/auth/hydra-maester/Makefile
index 970da58..98453ac 100644
--- a/core/auth/hydra-maester/Makefile
+++ b/core/auth/hydra-maester/Makefile
@@ -1,15 +1,23 @@
+clean: rm -rf hydra-maester/manager_*
+
 clone:
 	git clone --depth 1 --branch v0.0.20 https://github.com/ory/hydra-maester.git
 
-push_arm64: export GOOS=linux
-push_arm64: export GOARCH=arm64
-push_arm64: export CGO_ENABLED=0
-push_arm64: export GO111MODULE=on
-build:
-	cd hydra-maester && go build -o manager main.go
+build_arm64: export CGO_ENABLED=0
+build_arm64: export GO111MODULE=on
+build_arm64: export GOOS=linux
+build_arm64: export GOARCH=arm64
+build_arm64:
+	cd hydra-maester && go build -o manager_arm64 main.go
 
-image_arm64: build
-	docker build --tag=giolekva/ory-hydra-maester:latest . --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:
+	cd hydra-maester && go build -o manager_amd64 main.go
 
-push_arm64: image_arm64
-	docker push giolekva/ory-hydra-maester:latest
+build: clean build_arm64 build_amd64
+
+push: build
+	docker buildx build --tag=giolekva/ory-hydra-maester:latest . --platform=linux/arm64,linux/amd64 --push
diff --git a/core/auth/hydra/Dockerfile b/core/auth/hydra/Dockerfile
index 96ec8fa..ba49668 100644
--- a/core/auth/hydra/Dockerfile
+++ b/core/auth/hydra/Dockerfile
@@ -1,5 +1,7 @@
 FROM alpine:3.14.2
 
+ARG TARGETARCH
+
 RUN addgroup -S ory; \
     adduser -S ory -G ory -D -u 10000 -h /home/ory -s /bin/nologin; \
     chown -R ory:ory /home/ory
@@ -7,7 +9,13 @@
 RUN apk add -U --no-cache ca-certificates
 
 WORKDIR /downloads
-RUN wget https://github.com/ory/hydra/releases/download/v1.10.6/hydra_1.10.6_linux_arm64.tar.gz -O hydra.tar.gz
+RUN if [[ "${TARGETARCH}" == "amd64" ]]; \
+    then \
+      wget https://github.com/ory/hydra/releases/download/v1.10.6/hydra_1.10.6_linux_64bit.tar.gz -O hydra.tar.gz ; \
+    else \
+      wget https://github.com/ory/hydra/releases/download/v1.10.6/hydra_1.10.6_linux_${TARGETARCH}.tar.gz -O hydra.tar.gz ; \
+    fi
+
 RUN tar -xvf hydra.tar.gz
 RUN mv hydra /usr/bin
 
diff --git a/core/auth/hydra/Makefile b/core/auth/hydra/Makefile
index 6a91678..b0914b7 100644
--- a/core/auth/hydra/Makefile
+++ b/core/auth/hydra/Makefile
@@ -1,5 +1,2 @@
-image_arm64:
-	docker build --tag=giolekva/ory-hydra:latest . --platform=linux/arm64
-
-push_arm64: image_arm64
-	docker push giolekva/ory-hydra:latest
+push:
+	docker buildx build --tag=giolekva/ory-hydra:latest . --platform=linux/arm64,linux/amd64 --push
diff --git a/core/auth/kratos/Dockerfile b/core/auth/kratos/Dockerfile
index 9dea8e3..6b60233 100644
--- a/core/auth/kratos/Dockerfile
+++ b/core/auth/kratos/Dockerfile
@@ -1,12 +1,20 @@
 FROM alpine:3.14.2
 
+ARG TARGETARCH
+
 RUN addgroup -S ory; \
     adduser -S ory -G ory -D -u 10000 -h /home/ory -s /bin/nologin; \
     chown -R ory:ory /home/ory
 
 RUN apk add -U --no-cache ca-certificates
 
-RUN wget https://github.com/ory/kratos/releases/download/v0.7.6-alpha.1/kratos_0.7.6-alpha.1_linux_arm64.tar.gz -O kratos.tar.gz
+RUN if [[ "${TARGETARCH}" == "amd64" ]]; \
+    then \
+      wget https://github.com/ory/kratos/releases/download/v0.7.6-alpha.1/kratos_0.7.6-alpha.1_linux_64bit.tar.gz -O kratos.tar.gz ; \
+    else \
+      wget https://github.com/ory/kratos/releases/download/v0.7.6-alpha.1/kratos_0.7.6-alpha.1_linux_${TARGETARCH}.tar.gz -O kratos.tar.gz ; \
+    fi
+
 RUN tar -xvf kratos.tar.gz
 RUN mv kratos /usr/bin
 
diff --git a/core/auth/kratos/Makefile b/core/auth/kratos/Makefile
index ab5043a..3b803ed 100644
--- a/core/auth/kratos/Makefile
+++ b/core/auth/kratos/Makefile
@@ -1,12 +1,2 @@
-image:
-	docker build --tag=giolekva/ory-kratos:latest . --platform=linux/arm64
-
-push: image
-	docker push giolekva/ory-kratos:latest
-
-
-push_arm64: export GOOS=linux
-push_arm64: export GOARCH=arm64
-push_arm64: export CGO_ENABLED=0
-push_arm64: export GO111MODULE=on
-push_arm64: push
+push:
+	docker buildx build --tag=giolekva/ory-kratos:latest . --platform=linux/arm64,linux/amd64 --push
diff --git a/core/auth/ui/.gitignore b/core/auth/ui/.gitignore
index 254defd..dc33f72 100644
--- a/core/auth/ui/.gitignore
+++ b/core/auth/ui/.gitignore
@@ -1 +1,2 @@
-server
+server_arm64
+server_amd64
diff --git a/core/auth/ui/Dockerfile b/core/auth/ui/Dockerfile
index 8a76b08..980e40e 100644
--- a/core/auth/ui/Dockerfile
+++ b/core/auth/ui/Dockerfile
@@ -1,4 +1,6 @@
 FROM alpine:latest
 
-COPY server /usr/bin
+ARG TARGETARCH
+
+COPY server_${TARGETARCH} /usr/bin/server
 RUN chmod +x /usr/bin/server
diff --git a/core/auth/ui/Makefile b/core/auth/ui/Makefile
index 70bf15c..a401141 100644
--- a/core/auth/ui/Makefile
+++ b/core/auth/ui/Makefile
@@ -1,18 +1,19 @@
-build:
-	go build -o server *.go
-
 clean:
-	rm -f server
+	rm -f server_*
 
-image: clean build
-	docker build --tag=giolekva/auth-ui . --platform=linux/arm64
+build_arm64: export CGO_ENABLED=0
+build_arm64: export GO111MODULE=on
+build_arm64: export GOOS=linux
+build_arm64: export GOARCH=arm64
+build_arm64:
+	go build -o server_arm64 *.go
 
-push: image
-	docker push giolekva/auth-ui:latest
+build_amd64: export CGO_ENABLED=0
+build_amd64: export GO111MODULE=on
+build_amd64: export GOOS=linux
+build_amd64: export GOARCH=amd64
+build_amd64:
+	go build -o server_amd64 *.go
 
-
-push_arm64: export GOOS=linux
-push_arm64: export GOARCH=arm64
-push_arm64: export CGO_ENABLED=0
-push_arm64: export GO111MODULE=on
-push_arm64: push
+push: clean build_arm64 build_amd64
+	docker buildx build --tag=giolekva/auth-ui:latest . --platform=linux/arm64,linux/amd64 --push
diff --git a/core/nebula/Dockerfile b/core/nebula/Dockerfile
index 8377bdd..5f8d825 100644
--- a/core/nebula/Dockerfile
+++ b/core/nebula/Dockerfile
@@ -1,6 +1,8 @@
 FROM alpine:latest
 
-RUN wget https://github.com/slackhq/nebula/releases/download/v1.4.0/nebula-linux-arm64.tar.gz -O nebula.tar.gz
+ARG TARGETARCH
+
+RUN wget https://github.com/slackhq/nebula/releases/download/v1.4.0/nebula-linux-${TARGETARCH}.tar.gz -O nebula.tar.gz
 RUN tar -xvf nebula.tar.gz
 RUN mv nebula /usr/bin
 RUN mv nebula-cert /usr/bin
diff --git a/core/nebula/Makefile b/core/nebula/Makefile
index be9f307..c8b2f75 100644
--- a/core/nebula/Makefile
+++ b/core/nebula/Makefile
@@ -1,5 +1,2 @@
-image_arm64:
-	docker build --tag=giolekva/nebula:latest . --platform=linux/arm64
-
-push_arm64: image_arm64
-	docker push giolekva/nebula:latest
+push:
+	docker buildx build --tag=giolekva/nebula:latest . --platform=linux/arm64,linux/amd64 --push
diff --git a/core/nebula/controller/.gitignore b/core/nebula/controller/.gitignore
index 30d5788..17f70e0 100644
--- a/core/nebula/controller/.gitignore
+++ b/core/nebula/controller/.gitignore
@@ -1,3 +1,5 @@
-controller
+controller_arm64
+controller_amd64
 vendor
-web
+web_arm64
+web_amd64
\ No newline at end of file
diff --git a/core/nebula/controller/Dockerfile.controller b/core/nebula/controller/Dockerfile.controller
index fa0b2b7..82586e4 100644
--- a/core/nebula/controller/Dockerfile.controller
+++ b/core/nebula/controller/Dockerfile.controller
@@ -1,9 +1,11 @@
 FROM alpine:latest
 
-COPY controller /usr/bin/nebula-controller
+ARG TARGETARCH
+
+COPY controller_${TARGETARCH} /usr/bin/nebula-controller
 RUN chmod +x /usr/bin/nebula-controller
 
-RUN wget https://github.com/slackhq/nebula/releases/download/v1.4.0/nebula-linux-arm64.tar.gz -O nebula.tar.gz
+RUN wget https://github.com/slackhq/nebula/releases/download/v1.4.0/nebula-linux-${TARGETARCH}.tar.gz -O nebula.tar.gz
 RUN tar -xvf nebula.tar.gz
 RUN mv nebula-cert /usr/bin
 RUN chmod +x /usr/bin/nebula-cert
diff --git a/core/nebula/controller/Dockerfile.web b/core/nebula/controller/Dockerfile.web
index a82f86b..6c5a573 100644
--- a/core/nebula/controller/Dockerfile.web
+++ b/core/nebula/controller/Dockerfile.web
@@ -1,4 +1,6 @@
 FROM alpine:latest
 
-COPY web /usr/bin/nebula-web
+ARG TARGETARCH
+
+COPY web_${TARGETARCH} /usr/bin/nebula-web
 RUN chmod +x /usr/bin/nebula-web
diff --git a/core/nebula/controller/Makefile b/core/nebula/controller/Makefile
index 2104b79..a838f0b 100644
--- a/core/nebula/controller/Makefile
+++ b/core/nebula/controller/Makefile
@@ -1,36 +1,50 @@
 clean:
-	rm -f controller web
+	rm -f controller_* web_*
 
 generate:
 	rm -rf generated
 	./hack/generate.sh
 
-controller: export CGO_ENABLED=0
-controller: export GO111MODULE=on
-controller: export GOOS=linux
-controller: export GOARCH=arm64
-controller:
+controller_arm64: export CGO_ENABLED=0
+controller_arm64: export GO111MODULE=on
+controller_arm64: export GOOS=linux
+controller_arm64: export GOARCH=arm64
+controller_arm64:
 	go mod tidy
 	go mod vendor
-	go build -o controller main.go
+	go build -o controller_arm64 main.go
 
-web: export CGO_ENABLED=0
-web: export GO111MODULE=on
-web: export GOOS=linux
-web: export GOARCH=arm64
-web:
-	go build -o web web.go
+controller_amd64: export CGO_ENABLED=0
+controller_amd64: export GO111MODULE=on
+controller_amd64: export GOOS=linux
+controller_amd64: export GOARCH=amd64
+controller_amd64:
+	go mod tidy
+	go mod vendor
+	go build -o controller_amd64 main.go
 
-image_controller: controller
-	docker build -f Dockerfile.controller --tag=giolekva/nebula-controller:latest . --platform=linux/arm64
+controller: controller_arm64 controller_amd64
 
-image_web: web
-	docker build -f Dockerfile.web --tag=giolekva/nebula-web:latest . --platform=linux/arm64
+web_arm64: export CGO_ENABLED=0
+web_arm64: export GO111MODULE=on
+web_arm64: export GOOS=linux
+web_arm64: export GOARCH=arm64
+web_arm64:
+	go build -o web_arm64 web.go
 
-push_controller: image_controller
-	docker push giolekva/nebula-controller:latest
+web_amd64: export CGO_ENABLED=0
+web_amd64: export GO111MODULE=on
+web_amd64: export GOOS=linux
+web_amd64: export GOARCH=amd64
+web_amd64:
+	go build -o web_amd64 web.go
 
-push_web: image_web
-	docker push giolekva/nebula-web:latest
+web: web_arm64 web_amd64
 
-push_arm64: push_controller push_web
+push_controller: controller
+	docker buildx build -f Dockerfile.controller --tag=giolekva/nebula-controller:latest . --platform=linux/arm64,linux/amd64 --push
+
+push_web: web
+	docker buildx build -f Dockerfile.web --tag=giolekva/nebula-web:latest . --platform=linux/arm64,linux/amd64 --push
+
+push: push_controller push_web