From 4edd799d7a85cb51cf50a8dc0099a5d8acf7da88 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Thu, 14 Nov 2024 13:35:14 -0500 Subject: [PATCH] break up velero-builder stage to allow more concurrent layer builds. Signed-off-by: Tiger Kaovilai --- Dockerfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index b493c6662d..43c1994947 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ # limitations under the License. # Velero binary build section -FROM --platform=$BUILDPLATFORM golang:1.22-bookworm AS velero-builder +FROM --platform=$BUILDPLATFORM golang:1.22-bookworm AS velero-builder-base ARG GOPROXY ARG BIN @@ -41,13 +41,15 @@ RUN go mod download COPY . /go/src/github.com/vmware-tanzu/velero -RUN mkdir -p /output/usr/bin && \ - export GOARM=$( echo "${GOARM}" | cut -c2-) && \ - go build -o /output/${BIN} \ - -ldflags "${LDFLAGS}" ${PKG}/cmd/${BIN} && \ - go build -o /output/velero-helper \ - -ldflags "${LDFLAGS}" ${PKG}/cmd/velero-helper && \ - go clean -modcache -cache +RUN mkdir -p /output/usr/bin + +FROM velero-builder-base AS velero-builder-helper +RUN GOARM=$( echo "${GOARM}" | cut -c2-) go build -o /output/velero-helper \ +-ldflags "${LDFLAGS}" ${PKG}/cmd/velero-helper + +FROM velero-builder-base AS velero-builder +RUN GOARM=$( echo "${GOARM}" | cut -c2-) go build -o /output/${BIN} \ + -ldflags "${LDFLAGS}" ${PKG}/cmd/${BIN} # Restic binary build section FROM --platform=$BUILDPLATFORM golang:1.22-bookworm AS restic-builder @@ -99,6 +101,8 @@ LABEL maintainer="Xun Jiang " COPY --from=velero-builder /output / +COPY --from=velero-builder-helper /output / + COPY --from=restic-builder /output / USER cnb:cnb