From d8a51c535d75381a23bed7b536779d21c6077039 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Wed, 6 Nov 2024 22:02:30 -0500 Subject: [PATCH] Speedup multiarch using cross arch builds. This also fixes issue with CGO in my env. --- deploy/Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/deploy/Dockerfile b/deploy/Dockerfile index b3b137e..a4d6712 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -1,6 +1,8 @@ -FROM golang:1.20-bullseye AS build-plugin +FROM --platform=$BUILDPLATFORM golang:1.20-bullseye AS build-plugin ENV GOPROXY=https://proxy.golang.org ENV PROJECTPATH=/go/src/github.com/replicatedhq/local-volume-provider/local-volume-fileserver +ARG TARGETARCH +ARG BUILDPLATFORM WORKDIR $PROJECTPATH COPY Makefile ./ COPY go.mod ./ @@ -8,9 +10,9 @@ COPY go.sum ./ COPY cmd ./cmd COPY pkg ./pkg ARG VERSION=main -RUN CGO_ENABLED=0 go build -ldflags=" -X github.com/replicatedhq/local-volume-provider/pkg/version.version=$VERSION " -o /go/bin/local-volume-provider ./cmd/local-volume-provider +RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} go build -ldflags=" -X github.com/replicatedhq/local-volume-provider/pkg/version.version=$VERSION " -o /go/bin/local-volume-provider ./cmd/local-volume-provider -FROM golang:1.20-bullseye as build-fileserver +FROM --platform=$BUILDPLATFORM golang:1.20-bullseye AS build-fileserver ENV GOPROXY=https://proxy.golang.org ENV PROJECTPATH=/go/src/github.com/replicatedhq/local-volume-provider/local-volume-fileserver WORKDIR $PROJECTPATH @@ -20,7 +22,7 @@ COPY go.sum ./ COPY cmd ./cmd COPY pkg ./pkg ARG VERSION=main -RUN CGO_ENABLED=0 go build -ldflags=" -X github.com/replicatedhq/local-volume-provider/pkg/version.version=$VERSION " -o /go/bin/local-volume-fileserver ./cmd/local-volume-fileserver +RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} go build -ldflags=" -X github.com/replicatedhq/local-volume-provider/pkg/version.version=$VERSION " -o /go/bin/local-volume-fileserver ./cmd/local-volume-fileserver FROM debian:bullseye-slim RUN mkdir /plugins