From bc4a1080f72acc0a68f2f3138eb67998f82dad1a Mon Sep 17 00:00:00 2001 From: aleskandro Date: Wed, 18 Jan 2023 14:33:08 +0100 Subject: [PATCH 1/3] Let building the tectonic-console-builder possible on platforms different than x86_64 This commit will allow building the tectonic-console-builder on platforms different than x86_64. The installation of chrome is currently disabled as it is not shipped for arm64. --- Dockerfile.builder | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile.builder b/Dockerfile.builder index 823d4cc8dd1..e192f94fb48 100644 --- a/Dockerfile.builder +++ b/Dockerfile.builder @@ -30,12 +30,13 @@ RUN apt-get update \ libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb # ^^ additional Cypress dependencies: https://docs.cypress.io/guides/guides/continuous-integration.html#Dependencies -RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.20.4/bin/linux/amd64/kubectl && \ +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.20.4/bin/linux/$(go env GOARCH)/kubectl && \ chmod +x ./kubectl && \ mv ./kubectl /usr/local/bin/kubectl RUN cd /tmp && \ - wget --quiet -O /tmp/node.tar.gz http://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz && \ + wget --quiet -O /tmp/node.tar.gz \ + "http://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-$(go env GOARCH | sed 's/amd64/x64/').tar.gz" && \ tar xf node.tar.gz && \ rm -f /tmp/node.tar.gz && \ cd node-* && \ @@ -55,7 +56,8 @@ RUN cd /tmp && \ ln -s /usr/local/yarn/bin/yarn /usr/local/bin/yarn # Install Chrome for installer gui tests -RUN wget --quiet -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ +RUN test "$(go env GOARCH)" = amd64 || exit 0; \ + wget --quiet -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \ apt-get update && \ apt-get install --no-install-recommends -y -q \ From bd74dc0d54ab2ecc9885fe658925af8d04e0fbb5 Mon Sep 17 00:00:00 2001 From: aleskandro Date: Thu, 19 Jan 2023 08:22:17 +0100 Subject: [PATCH 2/3] Updates Dockerfile.product to have it working in the Prow CI 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. --- Dockerfile.product | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Dockerfile.product b/Dockerfile.product index 7eaf5ff0c05..3bfd5440184 100644 --- a/Dockerfile.product +++ b/Dockerfile.product @@ -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 \ From d9649c264d2f9a0a1c483efa98f35fd91866fae2 Mon Sep 17 00:00:00 2001 From: aleskandro Date: Tue, 24 Jan 2023 11:12:55 +0100 Subject: [PATCH 3/3] Move Dockerfile.product to Dockerfile and keep the first as a symlink --- Dockerfile | 77 ++++++++++++++++++++++++++++++++++++++------- Dockerfile.product | 78 +--------------------------------------------- 2 files changed, 67 insertions(+), 88 deletions(-) mode change 100644 => 120000 Dockerfile.product diff --git a/Dockerfile b/Dockerfile index 329956a5c99..3bfd5440184 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,77 @@ -FROM quay.io/coreos/tectonic-console-builder:v24 AS build - +################################################## +# +# go backend build +FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.19-openshift-4.13 AS gobuilder RUN mkdir -p /go/src/github.com/openshift/console/ ADD . /go/src/github.com/openshift/console/ WORKDIR /go/src/github.com/openshift/console/ -RUN ./build.sh +RUN ./build-backend.sh + + +################################################## +# +# nodejs frontend build +FROM registry.ci.openshift.org/ocp/builder:rhel-8-base-nodejs-openshift-4.13 AS nodebuilder + +ADD . . + +USER 0 + +ARG YARN_VERSION=v1.22.19 + +# bootstrap yarn so we can install and run the other tools. +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 -FROM openshift/origin-base +# 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 --from=build /go/src/github.com/openshift/console/frontend/public/dist /opt/bridge/static -COPY --from=build /go/src/github.com/openshift/console/bin/bridge /opt/bridge/bin/bridge -COPY --from=build /go/src/github.com/openshift/console/pkg/graphql/schema.graphql /pkg/graphql/schema.graphql +COPY $REMOTE_SOURCES $REMOTE_SOURCES_DIR -LABEL io.k8s.display-name="OpenShift Console" \ - io.k8s.description="This is a component of OpenShift Container Platform and provides a web console." \ - io.openshift.tags="openshift" \ - maintainer="Samuel Padgett " +# use dependencies provided by Cachito +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 \ + GECKODRIVER_SKIP_DOWNLOAD=true \ + CYPRESS_INSTALL_BINARY=0 + +# run the build +RUN container-entrypoint ./build-frontend.sh + + +################################################## +# +# actual base image for final product +FROM registry.ci.openshift.org/ocp/4.13:base +RUN mkdir -p /opt/bridge/bin +COPY --from=gobuilder /go/src/github.com/openshift/console/bin/bridge /opt/bridge/bin +COPY --from=nodebuilder /opt/app-root/src/frontend/public/dist /opt/bridge/static +COPY --from=gobuilder /go/src/github.com/openshift/console/pkg/graphql/schema.graphql /pkg/graphql/schema.graphql + +WORKDIR / # doesn't require a root user. USER 1001 CMD [ "/opt/bridge/bin/bridge", "--public-dir=/opt/bridge/static" ] + +LABEL \ + io.k8s.description="This is a component of OpenShift Container Platform and provides a web console." \ + com.redhat.component="openshift-enterprise-console-container" \ + maintainer="Samuel Padgett " \ + name="openshift3/ose-console" \ + License="Apache 2.0" \ + io.k8s.display-name="OpenShift Console" \ + vendor="Red Hat" \ + io.openshift.tags="openshift,console" + diff --git a/Dockerfile.product b/Dockerfile.product deleted file mode 100644 index 3bfd5440184..00000000000 --- a/Dockerfile.product +++ /dev/null @@ -1,77 +0,0 @@ -################################################## -# -# go backend build -FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.19-openshift-4.13 AS gobuilder -RUN mkdir -p /go/src/github.com/openshift/console/ -ADD . /go/src/github.com/openshift/console/ -WORKDIR /go/src/github.com/openshift/console/ -RUN ./build-backend.sh - - -################################################## -# -# nodejs frontend build -FROM registry.ci.openshift.org/ocp/builder:rhel-8-base-nodejs-openshift-4.13 AS nodebuilder - -ADD . . - -USER 0 - -ARG YARN_VERSION=v1.22.19 - -# bootstrap yarn so we can install and run the other tools. -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 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 \ - GECKODRIVER_SKIP_DOWNLOAD=true \ - CYPRESS_INSTALL_BINARY=0 - -# run the build -RUN container-entrypoint ./build-frontend.sh - - -################################################## -# -# actual base image for final product -FROM registry.ci.openshift.org/ocp/4.13:base -RUN mkdir -p /opt/bridge/bin -COPY --from=gobuilder /go/src/github.com/openshift/console/bin/bridge /opt/bridge/bin -COPY --from=nodebuilder /opt/app-root/src/frontend/public/dist /opt/bridge/static -COPY --from=gobuilder /go/src/github.com/openshift/console/pkg/graphql/schema.graphql /pkg/graphql/schema.graphql - -WORKDIR / -# doesn't require a root user. -USER 1001 - -CMD [ "/opt/bridge/bin/bridge", "--public-dir=/opt/bridge/static" ] - -LABEL \ - io.k8s.description="This is a component of OpenShift Container Platform and provides a web console." \ - com.redhat.component="openshift-enterprise-console-container" \ - maintainer="Samuel Padgett " \ - name="openshift3/ose-console" \ - License="Apache 2.0" \ - io.k8s.display-name="OpenShift Console" \ - vendor="Red Hat" \ - io.openshift.tags="openshift,console" - diff --git a/Dockerfile.product b/Dockerfile.product new file mode 120000 index 00000000000..1d1fe94df49 --- /dev/null +++ b/Dockerfile.product @@ -0,0 +1 @@ +Dockerfile \ No newline at end of file