From df39d933dbb210825500f1af009c1b642e299e5c Mon Sep 17 00:00:00 2001 From: "liheng.zms" Date: Fri, 10 Feb 2023 16:52:21 +0800 Subject: [PATCH] fix docker build arm64 failed Signed-off-by: liheng.zms --- Dockerfile_multiarch | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Dockerfile_multiarch b/Dockerfile_multiarch index e65b5735..eb0b740e 100644 --- a/Dockerfile_multiarch +++ b/Dockerfile_multiarch @@ -1,5 +1,7 @@ # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.18 as builder +ARG BASE_IMAGE=alpine +ARG BASE_IMAGE_VERION=3.17 +FROM --platform=$BUILDPLATFORM golang:1.18-alpine3.17 as builder WORKDIR /workspace @@ -13,15 +15,20 @@ COPY api/ api/ COPY pkg/ pkg/ # Build -ARG TARGETOS TARGETARCH -RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go +ARG TARGETOS +ARG TARGETARCH +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GO111MODULE=on go build -a -o manager main.go + +ARG BASE_IMAGE +ARG BASE_IMAGE_VERION +FROM ${BASE_IMAGE}:${BASE_IMAGE_VERION} + +RUN apk add --no-cache ca-certificates=~20220614-r4 bash=~5.2.15-r0 expat=~2.5.0-r0 \ + && rm -rf /var/cache/apk/* -# Use distroless as minimal base image to package the manager binary -# Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot WORKDIR / COPY --from=builder /workspace/manager . COPY lua_configuration /lua_configuration -USER 65532:65532 +USER 1000 ENTRYPOINT ["/manager"]