diff --git a/Dockerfile b/Dockerfile index c80f2087183..164a6fb9f5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ################################################## # # go backend build -FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.21-openshift-4.16 AS gobuilder +FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-openshift-4.17 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/ @@ -11,7 +11,7 @@ RUN ./build-backend.sh ################################################## # # nodejs frontend build -FROM registry.ci.openshift.org/ocp/builder:rhel-9-base-nodejs-openshift-4.16 AS nodebuilder +FROM registry.ci.openshift.org/ocp/builder:rhel-9-base-nodejs-openshift-4.17 AS nodebuilder ADD . . @@ -51,7 +51,7 @@ RUN container-entrypoint ./build-frontend.sh ################################################## # # actual base image for final product -FROM registry.ci.openshift.org/ocp/4.16:base-rhel9 +FROM registry.ci.openshift.org/ocp/4.17:base-rhel9 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 diff --git a/Dockerfile.builder b/Dockerfile.builder deleted file mode 100644 index db081cb5da4..00000000000 --- a/Dockerfile.builder +++ /dev/null @@ -1,56 +0,0 @@ -# Used for testing OpenShift console in CI. After editing this file: -# -# * Bump the builder version in `Dockerfile` and `builder-run.sh` -# * Commit the changes -# * Run `DOCKER_TAG= ./push-builder.sh` to update the image on quay -# (requires edit permission to the quay.io/coreos/tectonic-console-builder repo) -# -# You can test the image using `./builder-run.sh`. For instance: -# $ ./builder-run.sh ./build-backend.sh - -FROM golang:1.20-bullseye - -MAINTAINER Ed Rooth - CoreOS - -### For golang testing stuff -RUN go install github.com/jstemmer/go-junit-report@latest - -### Install NodeJS and yarn -ENV NODE_VERSION="v18.18.1" -ENV YARN_VERSION="v1.22.10" - -# yarn needs a home writable by any user running the container -ENV HOME /opt/home -RUN mkdir -p ${HOME} -RUN chmod 777 -R ${HOME} - -RUN apt-get update \ - && apt-get install --no-install-recommends -y -q \ - curl wget git unzip bzip2 jq expect \ - 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.27.1/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-$(go env GOARCH | sed 's/amd64/x64/').tar.gz" && \ - tar xf node.tar.gz && \ - rm -f /tmp/node.tar.gz && \ - cd node-* && \ - cp -r lib/node_modules /usr/local/lib/node_modules && \ - cp bin/node /usr/local/bin && \ - ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm -# so any container user can install global node modules if needed -RUN chmod 777 /usr/local/lib/node_modules -# cleanup -RUN rm -rf /tmp/node-v* - -RUN cd /tmp && \ - wget --quiet -O /tmp/yarn.tar.gz https://github.com/yarnpkg/yarn/releases/download/${YARN_VERSION}/yarn-${YARN_VERSION}.tar.gz && \ - tar xf yarn.tar.gz && \ - rm -f /tmp/yarn.tar.gz && \ - mv /tmp/yarn-${YARN_VERSION} /usr/local/yarn && \ - ln -s /usr/local/yarn/bin/yarn /usr/local/bin/yarn diff --git a/Dockerfile.cypress b/Dockerfile.cypress new file mode 100644 index 00000000000..87c45548e59 --- /dev/null +++ b/Dockerfile.cypress @@ -0,0 +1,68 @@ +################################################## +# +# cypress image +FROM cypress/included:13.10.0 + +################################################## +# +# go backend build +FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-openshift-4.17 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-9-base-nodejs-openshift-4.17 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/ + +# run the build +RUN container-entrypoint ./build-frontend.sh + + +################################################## +# +# actual base image for final product +FROM registry.ci.openshift.org/ocp/4.17:base-rhel9 +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" ] + + diff --git a/Dockerfile.dev b/Dockerfile.dev index 8c09cef611b..2d8c7a9ad9d 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,15 +1,26 @@ # Dockerfile to build console image from pre-built front end. -FROM quay.io/coreos/tectonic-console-builder:v26 AS build +################################################## +# +# go backend build +FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-openshift-4.17 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 -FROM openshift/origin-base -COPY --from=build /go/src/github.com/openshift/console/bin/bridge /opt/bridge/bin/bridge + +################################################## +# +# copy local pre-built nodejs frontend build +FROM registry.ci.openshift.org/ocp/4.17:base-rhel9 +RUN mkdir -p /opt/bridge/bin +COPY --from=gobuilder /go/src/github.com/openshift/console/bin/bridge /opt/bridge/bin/bridge COPY ./frontend/public/dist /opt/bridge/static -COPY ./pkg/graphql/schema.graphql /pkg/graphql/schema.graphql +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" ] diff --git a/Dockerfile.plugins.demo b/Dockerfile.plugins.demo index ef2280e7db5..e43c7543531 100644 --- a/Dockerfile.plugins.demo +++ b/Dockerfile.plugins.demo @@ -3,7 +3,38 @@ # See dynamic-demo-plugin/README.md for details. # Stage 0: build the demo plugin -FROM quay.io/coreos/tectonic-console-builder:v26 AS build +FROM registry.ci.openshift.org/ocp/builder:rhel-9-base-nodejs-openshift-4.17 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 cypress binary as part of module installs +ENV CYPRESS_INSTALL_BINARY=0 RUN mkdir -p /src/console COPY . /src/console @@ -16,16 +47,16 @@ RUN yarn install && \ yarn build # Stage 1: build the target image -FROM node:10 +FROM node:18 -COPY --from=build /src/console/dynamic-demo-plugin/dist /opt/console-plugin-demo/static -COPY --from=build /src/console/dynamic-demo-plugin/node_modules /opt/console-plugin-demo/node_modules -COPY --from=build /src/console/dynamic-demo-plugin/http-server.sh /opt/console-plugin-demo/http-server.sh +COPY --from=nodebuilder /src/console/dynamic-demo-plugin/dist /opt/console-plugin-demo/static +COPY --from=nodebuilder /src/console/dynamic-demo-plugin/node_modules /opt/console-plugin-demo/node_modules +COPY --from=nodebuilder /src/console/dynamic-demo-plugin/http-server.sh /opt/console-plugin-demo/http-server.sh LABEL io.k8s.display-name="OpenShift Console Demo Plugin" \ - io.k8s.description="Sample OpenShift Console dynamic plugin used for testing purposes." \ - io.openshift.tags="openshift" \ - maintainer="Vojtech Szocs " + io.k8s.description="Sample OpenShift Console dynamic plugin used for testing purposes." \ + io.openshift.tags="openshift" \ + maintainer="Vojtech Szocs " USER 1001 diff --git a/Dockerfile.plugins.demo2 b/Dockerfile.plugins.demo.dev similarity index 90% rename from Dockerfile.plugins.demo2 rename to Dockerfile.plugins.demo.dev index ced9ed96174..30a7a4bef28 100644 --- a/Dockerfile.plugins.demo2 +++ b/Dockerfile.plugins.demo.dev @@ -1,3 +1,5 @@ +# Dockerfile to build console-demo-plugin image from pre-built front end. +# # This image is used for testing OpenShift Console dynamic plugin capabilities. # # See dynamic-demo-plugin/README.md for details. @@ -11,7 +13,7 @@ # yarn build # Stage 1: build the target image -FROM node:10 +FROM node:18 COPY ./dynamic-demo-plugin/dist /opt/console-demo-plugin/static COPY ./dynamic-demo-plugin/node_modules /opt/console-demo-plugin/node_modules diff --git a/Dockerfile.product.nodejs b/Dockerfile.product.nodejs deleted file mode 100644 index e8406d55d1a..00000000000 --- a/Dockerfile.product.nodejs +++ /dev/null @@ -1,16 +0,0 @@ -FROM openshift/origin-release:nodejs8 - -COPY . /go/src/github.com/openshift/console/ -WORKDIR /go/src/github.com/openshift/console/ - -RUN ./build-frontend.sh \ -&& rm -rf /tmp/* -# remove temporary files -# created while building frontend assets. - -LABEL \ - io.k8s.description="This is a NodeJS 8 builder image for building the OpenShift Container Platform web console." \ - com.redhat.component="openshift-nodejs-builder-container" \ - name="openshift3/console-nodejs-builder" \ - vendor="Red Hat" \ - diff --git a/README.md b/README.md index 694ba1f1479..17971b2fb99 100644 --- a/README.md +++ b/README.md @@ -108,25 +108,6 @@ In order to enable the monitoring UI and see the "Observe" navigation item while export BRIDGE_PLUGINS="monitoring-plugin=http://localhost:9001" ``` -#### Updating `tectonic-console-builder` image -Updating `tectonic-console-builder` image is needed whenever there is a change in the build-time dependencies and/or go versions. - -In order to update the `tectonic-console-builder` to a new version i.e. v27, follow these steps: - -1. Update the `tectonic-console-builder` image tag in files listed below: - - .ci-operator.yaml - - Dockerfile.dev - - Dockerfile.plugins.demo - For example, `tectonic-console-builder:27` -2. Update the dependencies in Dockerfile.builder file i.e. v18.0.0. -3. Run `./push-builder.sh` script build and push the updated builder image to quay.io. - Note: You can test the image using `./builder-run.sh ./build-backend.sh`. - To update the image on quay.io, you need edit permission to the quay.io/coreos/ tectonic-console-builder repo. -4. Lastly, update the mapping of `tectonic-console-builder` image tag in - [openshift/release](https:// github.com/openshift/release/blob/master/core-services/image-mirroring/supplemental-ci-images/mapping_supplemental_ci_images_ci) repository. - Note: There could be scenario were you would have to add the new image reference in the "mapping_supplemental_ci_images_ci" file, i.e. to avoid CI downtime for upcoming release cycle. - Optional: Request for the [rhel-8-base-nodejs-openshift-4.15](https://github.com/openshift-eng/ocp-build-data/pull/3775/files) nodebuilder update if it doesn't match the node version in `tectonic-console-builder`. - #### CodeReady Containers If you want to use CodeReady for local development, first make sure [it is set up](https://crc.dev/crc/#setting-up-codeready-containers_gsg), and the [OpenShift cluster is started](https://crc.dev/crc/#starting-the-virtual-machine_gsg). diff --git a/builder-run.sh b/builder-run.sh deleted file mode 100755 index c994543e8ee..00000000000 --- a/builder-run.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# -# USAGE: -# -# With env vars: -# MYVAR=foo OTHERVAR=bar DOCKER_ENV=MYVAR,OTHERVAR ./builder-run.sh ./my-script --my-script-arg1 --my-script-arg2 -# -# Without env vars: -# ./builder-run.sh ./my-script --my-script-arg1 --my-script-arg2 - -BUILDER_IMAGE="quay.io/coreos/tectonic-console-builder:v26" - -# forward whitelisted env variables to docker -ENV_STR=() -VOLUME_MOUNT=() -for VAR in ${DOCKER_ENV//,/ }; do - if [ "$VAR" = 'KUBECONFIG' ] - then - VOLUME_MOUNT=("-v" "$KUBECONFIG:/kube/config") - ENV_STR+=("-e" "KUBECONFIG=/kube/config") - else - ENV_STR+=("-e" "$VAR=${!VAR}") - fi -done - -docker run "${ENV_STR[@]}" --rm --net=host \ - --user="${BUILDER_RUN_USER}" \ - "${VOLUME_MOUNT[@]}" \ - -v "$(pwd)":/go/src/github.com/openshift/console \ - --shm-size=512m \ - -w /go/src/github.com/openshift/console \ - "$BUILDER_IMAGE" "$@" diff --git a/push-builder.sh b/push-builder.sh deleted file mode 100755 index c8a0fe91eab..00000000000 --- a/push-builder.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# This script pushes the builder docker image to quay.io. You'll need -# it when you introduce new build-time dependencies or change go -# versions, etc. - -if [ -z "${DOCKER_TAG}" ]; then - echo "Please provide DOCKER_TAG env var and try again." - exit 1 -fi - -DOCKER_IMAGE=quay.io/coreos/tectonic-console-builder:${DOCKER_TAG} - -docker build --rm=true -t "${DOCKER_IMAGE}" - < Dockerfile.builder -docker push "${DOCKER_IMAGE}" - -echo "Pushed ${DOCKER_IMAGE}"