Skip to content

Commit

Permalink
Speedup multiarch using cross arch builds. (#66)
Browse files Browse the repository at this point in the history
This also fixes issue with CGO in my env.
  • Loading branch information
kaovilai authored Nov 7, 2024
1 parent 7c78cfd commit 2699d52
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
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 ./
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
Expand All @@ -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
Expand Down

0 comments on commit 2699d52

Please sign in to comment.