From 898f4b88881efb3f3a4c0960fe0b0186fd16d13f Mon Sep 17 00:00:00 2001 From: watchword Date: Wed, 6 Sep 2023 13:58:07 +0800 Subject: [PATCH] Update Dockerfile to support multiarch build Replace go compile args to TARGETOS and TARGETARCH to support multiarch compile Signed-off-by: Allen Chen Signed-off-by: watchword --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 19f50ddd..b110cbcb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # -FROM golang:1.17.5-alpine3.15 AS build +FROM --platform=${BUILDPLATFORM} golang:1.17.5-alpine3.15 AS build +ARG TARGETARCH +ARG TARGETOS WORKDIR /bfe COPY . . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=`cat VERSION`" +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-X main.version=`cat VERSION`" FROM alpine:3.15 AS run RUN apk update && apk add --no-cache ca-certificates