From 1bc121b23b623375f68fc507d71682b3e278152a Mon Sep 17 00:00:00 2001 From: nickboldt Date: Mon, 19 Jul 2021 12:06:08 -0300 Subject: [PATCH] build: CRW-1956 collect zips and restic vendor sources earlier in the process, so that downstream bootstrap build can simply stop at the WORKDIR line to save time Change-Id: I20a61cfaceb1ba91dd87e266d3224b04dd5187aa Signed-off-by: nickboldt --- Dockerfile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5381a381f..84e1669f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,14 @@ ARG DEV_WORKSPACE_CONTROLLER_VERSION="main" ARG DEV_WORKSPACE_CHE_OPERATOR_VERSION="main" USER root +# upstream, download zips for every build +# downstream, copy prefetched asset-*.zip into /tmp, and collect vendored sources for restic too +RUN mkdir -p $GOPATH/restic && \ + curl -sSLo- https://api.github.com/repos/restic/restic/tarball/${RESTIC_TAG} | tar --strip-components=1 -xz -C $GOPATH/restic && \ + cd $GOPATH/restic && go mod vendor && \ + curl -sSLo /tmp/asset-devworkspace-operator.zip https://api.github.com/repos/devfile/devworkspace-operator/zipball/${DEV_WORKSPACE_CONTROLLER_VERSION} && \ + curl -sSLo /tmp/asset-devworkspace-che-operator.zip https://api.github.com/repos/che-incubator/devworkspace-che-operator/zipball/${DEV_WORKSPACE_CHE_OPERATOR_VERSION} + WORKDIR /che-operator # Copy the Go Modules manifests COPY go.mod go.mod @@ -30,12 +38,6 @@ COPY templates/ templates/ COPY pkg/ pkg/ COPY vendor/ vendor/ -# upstream, download zips for every build -# downstream, copy prefetched asset-*.zip into /tmp -RUN curl -sSLo /tmp/asset-devworkspace-operator.zip https://api.github.com/repos/devfile/devworkspace-operator/zipball/${DEV_WORKSPACE_CONTROLLER_VERSION} && \ - curl -sSLo /tmp/asset-devworkspace-che-operator.zip https://api.github.com/repos/che-incubator/devworkspace-che-operator/zipball/${DEV_WORKSPACE_CHE_OPERATOR_VERSION} && \ - curl -sSLo /tmp/asset-restic.zip https://api.github.com/repos/restic/restic/zipball/${RESTIC_TAG} - # build operator RUN export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH="amd64"; elif [[ ${ARCH} == "aarch64" ]]; then export ARCH="arm64"; fi && \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o che-operator main.go @@ -49,11 +51,8 @@ RUN unzip /tmp/asset-devworkspace-che-operator.zip */deploy/deployment/* -d /tmp mv /tmp/che-incubator-devworkspace-che-operator-*/deploy /tmp/devworkspace-che-operator/templates/ # Build restic. Needed for backup / restore capabilities -RUN mkdir -p $GOPATH/restic && cd $GOPATH/restic && \ - unzip /tmp/asset-restic.zip -d /tmp && \ - mv /tmp/restic-*/* $GOPATH/restic && \ +RUN cd $GOPATH/restic && \ export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH="amd64"; elif [[ ${ARCH} == "aarch64" ]]; then export ARCH="arm64"; fi && \ - go mod vendor && \ GOOS=linux GOARCH=${ARCH} CGO_ENABLED=0 go build -mod=vendor -o /tmp/restic/restic ./cmd/restic # https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal