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 (#946)

Change-Id: I20a61cfaceb1ba91dd87e266d3224b04dd5187aa
Signed-off-by: nickboldt <nboldt@redhat.com>
pull/944/head
Nick Boldt 2021-07-19 15:27:05 -03:00 committed by GitHub
parent f555494a7d
commit a7da2a2912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 10 deletions

View File

@ -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