Skip to content

Commit

Permalink
break up velero-builder stage to allow more concurrent layer builds.
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Nov 14, 2024
1 parent c9938f9 commit 4edd799
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -99,6 +101,8 @@ LABEL maintainer="Xun Jiang <[email protected]>"

COPY --from=velero-builder /output /

COPY --from=velero-builder-helper /output /

COPY --from=restic-builder /output /

USER cnb:cnb
Expand Down

0 comments on commit 4edd799

Please sign in to comment.