From b6cbd99bfa26240fbee56acbeaa166517ae91036 Mon Sep 17 00:00:00 2001 From: Ali Ariff Date: Wed, 12 Aug 2020 14:32:54 +0200 Subject: [PATCH 1/3] Support multi-arch Signed-off-by: Ali Ariff --- Dockerfile | 24 +++++++++++++++++++----- README.md | 7 +++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3741edc..f1d7464 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,27 @@ -FROM golang:1.11.6-stretch as golang +ARG BUILDPLATFORM=linux/amd64 + +FROM --platform=$BUILDPLATFORM golang:1.11.6-stretch as golang WORKDIR /go/src/github.com/buoyantio/bb ADD . /go/src/github.com/buoyantio/bb RUN mkdir -p /out RUN ./bin/dep ensure -RUN go build -o /out/bb . +ARG TARGETARCH +RUN GOOS=linux GOARCH=$TARGETARCH go build -o /out/bb . + +FROM debian:buster-20200514-slim +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + dnsutils \ + iptables \ + jq \ + nghttp2 \ + ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +# We still rely on old iptables-legacy syntax. +RUN update-alternatives --set iptables /usr/sbin/iptables-legacy \ + && update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy -FROM gcr.io/linkerd-io/base:2019-02-19.01 -RUN apt-get update -RUN apt-get install -y ca-certificates COPY --from=golang /out /out ENTRYPOINT ["/out/bb"] diff --git a/README.md b/README.md index fc0e709..a24d158 100644 --- a/README.md +++ b/README.md @@ -124,3 +124,10 @@ You can then use `curl`to query the service: $ curl `minikube -n bb-readme service bb-readme-gateway-svc --url` {"requestUid":"in:http-sid:point-to-point-channel-grpc:-1-h1:8080-66349706","payload":"BANANA"} + +## Build Multi-Arch Images with Buildx + + docker buildx build . \ + --platform linux/amd64,linux/arm64,linux/arm/v7 \ + --push \ + --tag buoyantio/bb: From 99355b919b16c5947825cf4734868a085e6d8d01 Mon Sep 17 00:00:00 2001 From: Ali Ariff Date: Thu, 13 Aug 2020 01:00:43 +0200 Subject: [PATCH 2/3] Update style Signed-off-by: Ali Ariff --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1d7464..0f29ba5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ iptables \ jq \ nghttp2 \ - ca-certificates && \ - rm -rf /var/lib/apt/lists/* + ca-certificates \ + && rm -rf /var/lib/apt/lists/* # We still rely on old iptables-legacy syntax. RUN update-alternatives --set iptables /usr/sbin/iptables-legacy \ From d231c18850aa90a8fee271881e7cbfa789c75730 Mon Sep 17 00:00:00 2001 From: Ali Ariff Date: Thu, 13 Aug 2020 01:05:58 +0200 Subject: [PATCH 3/3] Add instruction to create builder instance Signed-off-by: Ali Ariff --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a24d158..38a4ac7 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,14 @@ You can then use `curl`to query the service: ## Build Multi-Arch Images with Buildx +Create the builder instance: + + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker buildx create --name=multiarch-builder --driver=docker-container --use + docker buildx inspect multiarch-builder --bootstrap + +Build the images: + docker buildx build . \ --platform linux/amd64,linux/arm64,linux/arm/v7 \ --push \