From a5415af9e1698a7eb34218cd59a709771755d9fc Mon Sep 17 00:00:00 2001 From: watchword Date: Fri, 4 Oct 2024 18:22:28 +0800 Subject: [PATCH] Update Dockerfile to support multiarch build (#1120) Replace go compile args to TARGETOS and TARGETARCH to support multiarch compile Signed-off-by: Allen Chen --- 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