Skip to content

Commit

Permalink
build: CRW-1956 collect zips and restic vendor sources earlier in the…
Browse files Browse the repository at this point in the history
… process, so that downstream bootstrap build can simply stop at the WORKDIR line to save time (#946)

Change-Id: I20a61cfaceb1ba91dd87e266d3224b04dd5187aa
Signed-off-by: nickboldt <[email protected]>
  • Loading branch information
nickboldt authored Jul 19, 2021
1 parent f555494 commit a7da2a2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a7da2a2

Please sign in to comment.