From 2699d52297fca643c4dcad897790e4bc8cab1549 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Thu, 7 Nov 2024 13:53:00 -0500 Subject: [PATCH] Speedup multiarch using cross arch builds. (#66) 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..82151f8 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -1,6 +1,8 @@ -FROM golang:1.20-bullseye AS build-plugin +FROM --platform=$BUILDPLATFORM golang:1.22-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.22-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