Skip to content

Commit

Permalink
Updates Dockerfile.product to have it working in the Prow CI
Browse files Browse the repository at this point in the history
Dockerfile.product considers the build engine providing (a) cachito-backed cache artifacts for the dependencies and (b) a cached yarn. This commit enables builder engines not providing caching artifacts to build the Dockerfile.product image by pulling the packages from other remote sources when the cached files are not available.
  • Loading branch information
aleskandro committed Jan 20, 2023
1 parent bc4a108 commit bd74dc0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Dockerfile.product
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,29 @@ ADD . .

USER 0

ARG YARN_VERSION=v1.22.19

# bootstrap yarn so we can install and run the other tools.
RUN container-entrypoint npm install ./artifacts/yarn-v1.22.19.tar.gz
RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tar.gz; \
if [ -f ${CACHED_YARN} ]; then \
npm install ${CACHED_YARN}; \
else \
npm install https://github.com/yarnpkg/yarn/releases/download/${YARN_VERSION}/yarn-${YARN_VERSION}.tar.gz; \
fi

# The REMOTE_SOURCES value is set by the build system to indicate the location of the cachito-backed artifacts cache.
# As cachito might not be available in all environments, we need to make sure the value is set before trying to use it and
# that the COPY layer below doesn't fail. Setting it to be the Dockerfile itself is fairly safe, as it will always be
# available.
ARG REMOTE_SOURCES=./Dockerfile.product
ARG REMOTE_SOURCE_DIR=/tmp/remote-sources

COPY $REMOTE_SOURCES $REMOTE_SOURCES_DIR

# use dependencies provided by Cachito
RUN cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/registry-ca.pem . \
&& cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/frontend/{.npmrc,.yarnrc,yarn.lock} frontend/
RUN test -d ${REMOTE_SOURCES}/cachito-gomod-with-deps || exit 0; \
cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/registry-ca.pem . \
&& cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/frontend/{.npmrc,.yarnrc,yarn.lock} frontend/

# prevent download of chromedriver, geckodriver, and the cypress binary as part of module installs
ENV CHROMEDRIVER_SKIP_DOWNLOAD=true \
Expand Down

0 comments on commit bd74dc0

Please sign in to comment.