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