diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 522306ad1..e3eeeff08 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -51,11 +51,23 @@ jobs: echo "Removing large packages" sudo docker image prune --all --force sudo docker builder prune -a + sudo apt-get remove -y '^aspnetcore-.*' || true sudo apt-get remove -y '^dotnet-.*' || true sudo apt-get remove -y '^llvm-.*' || true + sudo apt-get remove -y '^temurin-.*' || true sudo apt-get remove -y 'monodoc-http' || true sudo apt-get remove -y 'php.*' || true - sudo apt-get remove -y azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel || true + sudo apt-get remove -y 'ruby.*' || true + sudo apt-get remove -y mercurial-common || true + sudo apt-get remove -y azure-cli || true + sudo apt-get remove -y google-cloud-cli-anthoscli || true + sudo apt-get remove -y google-cloud-sdk || true + sudo apt-get remove -y hhvm || true + sudo apt-get remove -y google-chrome-stable || true + sudo apt-get remove -y firefox || true + sudo apt-get remove -y microsoft-edge-stable || true + sudo apt-get remove -y powershell || true + sudo apt-get remove -y mono-devel || true sudo apt-get autoremove -y || true sudo apt-get clean df -h diff --git a/.github/workflows/coherence-matrix.yaml b/.github/workflows/coherence-matrix.yaml index ff6fe7bab..0f46068b5 100644 --- a/.github/workflows/coherence-matrix.yaml +++ b/.github/workflows/coherence-matrix.yaml @@ -24,6 +24,7 @@ env: MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} LOAD_KIND: true GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/.github/workflows/compatibility-tests.yaml b/.github/workflows/compatibility-tests.yaml index 3bff5ce18..b190c5e30 100644 --- a/.github/workflows/compatibility-tests.yaml +++ b/.github/workflows/compatibility-tests.yaml @@ -28,6 +28,7 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/.github/workflows/istio-tests.yaml b/.github/workflows/istio-tests.yaml index 1a05d0844..47dc0dd34 100644 --- a/.github/workflows/istio-tests.yaml +++ b/.github/workflows/istio-tests.yaml @@ -28,6 +28,7 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/.github/workflows/k3d-tests.yaml b/.github/workflows/k3d-tests.yaml index 1947a6f74..413bcf5c5 100644 --- a/.github/workflows/k3d-tests.yaml +++ b/.github/workflows/k3d-tests.yaml @@ -28,6 +28,7 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/.github/workflows/k8s-matrix.yaml b/.github/workflows/k8s-matrix.yaml index e6bb6aa86..881a9fb07 100644 --- a/.github/workflows/k8s-matrix.yaml +++ b/.github/workflows/k8s-matrix.yaml @@ -31,6 +31,7 @@ env: MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} LOAD_KIND: true GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/.github/workflows/minikube-matrix.yaml b/.github/workflows/minikube-matrix.yaml index a05010a30..77321fa40 100644 --- a/.github/workflows/minikube-matrix.yaml +++ b/.github/workflows/minikube-matrix.yaml @@ -31,6 +31,7 @@ env: MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} LOAD_KIND: false GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: @@ -40,19 +41,19 @@ jobs: fail-fast: false matrix: matrixName: + - v1.34 - v1.33 - v1.32 - v1.31 - - v1.30 include: + - matrixName: v1.34 + k8s: v1.34.0 - matrixName: v1.33 k8s: v1.33.1 - matrixName: v1.32 k8s: v1.32.5 - matrixName: v1.31 k8s: v1.31.9 - - matrixName: v1.30 - k8s: v1.30.13 steps: - uses: actions/checkout@v4 @@ -68,17 +69,33 @@ jobs: dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100 df -h echo "Removing large packages" + sudo docker image prune --all --force + sudo docker builder prune -a + sudo apt-get remove -y '^aspnetcore-.*' || true sudo apt-get remove -y '^dotnet-.*' || true sudo apt-get remove -y '^llvm-.*' || true + sudo apt-get remove -y '^temurin-.*' || true sudo apt-get remove -y 'monodoc-http' || true sudo apt-get remove -y 'php.*' || true - sudo apt-get remove -y azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel || true + sudo apt-get remove -y 'ruby.*' || true + sudo apt-get remove -y mercurial-common || true + sudo apt-get remove -y azure-cli || true + sudo apt-get remove -y google-cloud-cli-anthoscli || true + sudo apt-get remove -y google-cloud-sdk || true + sudo apt-get remove -y hhvm || true + sudo apt-get remove -y google-chrome-stable || true + sudo apt-get remove -y firefox || true + sudo apt-get remove -y microsoft-edge-stable || true + sudo apt-get remove -y powershell || true + sudo apt-get remove -y mono-devel || true sudo apt-get autoremove -y || true sudo apt-get clean df -h echo "Removing large directories" rm -rf /usr/share/dotnet/ sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf /opt/hostedtoolcache/CodeQL df -h - name: Set up JDK @@ -121,11 +138,13 @@ jobs: kubectl version kubectl get nodes docker pull gcr.io/distroless/java - docker pull gcr.io/distroless/java11-debian11 - docker pull gcr.io/distroless/java17-debian11 docker pull gcr.io/distroless/java17-debian12 docker pull gcr.io/distroless/java21-debian12 - ./hack/k8s-certification.sh + make build-operator + make build-basic-test-image + make build-compatibility-image + make helm-chart + make certification-test - uses: actions/upload-artifact@v4 if: ${{ failure() || cancelled() }} diff --git a/.github/workflows/prometheus-tests.yaml b/.github/workflows/prometheus-tests.yaml index 00a2e0b80..5d635a9b6 100644 --- a/.github/workflows/prometheus-tests.yaml +++ b/.github/workflows/prometheus-tests.yaml @@ -28,6 +28,7 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/.github/workflows/tanzu-tests.yaml b/.github/workflows/tanzu-tests.yaml index 8eabd809e..e7141c102 100644 --- a/.github/workflows/tanzu-tests.yaml +++ b/.github/workflows/tanzu-tests.yaml @@ -28,6 +28,7 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/.github/workflows/trivy.yaml b/.github/workflows/trivy.yaml index 9c9decdf8..51bf49f85 100644 --- a/.github/workflows/trivy.yaml +++ b/.github/workflows/trivy.yaml @@ -20,6 +20,7 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_SPRING_CNBP: true jobs: build: diff --git a/Makefile b/Makefile index f3564b0d1..2786f6a8a 100644 --- a/Makefile +++ b/Makefile @@ -177,7 +177,7 @@ OPERATOR_REPO_IMAGE := $(OPERATOR_REPO_PREFIX):$(OPERATOR_IMAGE_TAG) # ---------------------------------------------------------------------------------------------------------------------- # The test application images used in integration tests # ---------------------------------------------------------------------------------------------------------------------- -TEST_APPLICATION_IMAGE := $(OPERATOR_IMAGE_REGISTRY)/operator-test:1.0.0 +TEST_APPLICATION_IMAGE ?= $(OPERATOR_IMAGE_REGISTRY)/operator-test:1.0.0 TEST_COMPATIBILITY_IMAGE := $(OPERATOR_IMAGE_REGISTRY)/operator-test-compatibility:1.0.0 TEST_APPLICATION_IMAGE_CLIENT := $(OPERATOR_IMAGE_REGISTRY)/operator-test-client:1.0.0 TEST_APPLICATION_IMAGE_HELIDON := $(OPERATOR_IMAGE_REGISTRY)/operator-test-helidon:1.0.0 @@ -1283,6 +1283,57 @@ oc-login: # Allow anything in operator-test to pull images # oc policy add-role-to-user system:image-puller system:serviceaccounts:operator-test --namespace=oracle +REDHAT_EXAMPLE_BASE_IMAGE ?= registry.redhat.io/ubi9/openjdk-21:latest +REDHAT_EXAMPLE_IMAGE_NAME := coherence-operator-operand +REDHAT_EXAMPLE_IMAGE := $(OPERATOR_RELEASE_REGISTRY)/$(REDHAT_EXAMPLE_IMAGE_NAME):$(COHERENCE_VERSION_LTS)-rh +OPENSHIFT_COHERENCE_COMPONENT_ID := 68d28054a49e977fe49f4234 +OPENSHIFT_API_KEY ?= FAKE +SUBMIT_RESULTS ?= false + +.PHONY: build-redhat-coherence-image +build-redhat-coherence-image: $(BUILD_TARGETS)/java ## Build the Red Hat Operator operand image + ./mvnw $(MAVEN_BUILD_OPTS) -B -f java/operator-test clean package -DskipTests + mkdir -p java/operator-test/target/docker/licenses || true + cp LICENSE.txt java/operator-test/target/docker/licenses/LICENSE.txt + export DOCKER_CMD=$(DOCKER_CMD) \ + && export PROJECT_ROOT=$(CURRDIR) \ + && export BUILD_ALL_IMAGES=true \ + && export COHERENCE_VERSION=$(COHERENCE_VERSION_LTS) \ + && export REDHAT_REGISTRY_USERNAME=$(REDHAT_REGISTRY_USERNAME) \ + && export REDHAT_REGISTRY_PASSWORD=$(REDHAT_REGISTRY_PASSWORD) \ + && export AMD_BASE_IMAGE=$(REDHAT_EXAMPLE_BASE_IMAGE) \ + && export ARM_BASE_IMAGE=$(REDHAT_EXAMPLE_BASE_IMAGE) \ + && export IMAGE_NAME=$(REDHAT_EXAMPLE_IMAGE) \ + && export IMAGE_ARCH=$(IMAGE_ARCH) \ + && export MAIN_CLASS="com.tangosol.net.Coherence" \ + && export VERSION=$(VERSION) \ + && export REVISION=$(GITCOMMIT) \ + && export NO_DOCKER_DAEMON=$(NO_DOCKER_DAEMON) \ + && export DOCKER_CMD=$(DOCKER_CMD) \ + && $(SCRIPTS_DIR)/buildah/run-buildah.sh BUILD + +.PHONY: push-redhat-coherence-image +push-redhat-coherence-image: ## Push the Red Hat Operator operand image + chmod +x $(SCRIPTS_DIR)/buildah/run-buildah.sh + export IMAGE_NAME=$(REDHAT_EXAMPLE_IMAGE) \ + export IMAGE_NAME_AMD=$(REDHAT_EXAMPLE_IMAGE)-amd64 \ + export IMAGE_NAME_ARM=$(REDHAT_EXAMPLE_IMAGE)-arm64 \ + && export IMAGE_NAME_REGISTRY=$(OPERATOR_RELEASE_REGISTRY) \ + && export VERSION=$(COHERENCE_VERSION_LTS) \ + && export REVISION=$(COHERENCE_VERSION_LTS) \ + && export NO_DOCKER_DAEMON=$(NO_DOCKER_DAEMON) \ + && export DOCKER_CMD=$(DOCKER_CMD) \ + && $(SCRIPTS_DIR)/buildah/run-buildah.sh PUSH + +.PHONY: redhat-coherence-image-preflight +redhat-coherence-image-preflight: ## Run the OpenShift preflight tests against the Operator operand image in a container + chmod +x $(SCRIPTS_DIR)/openshift/run-coherence-preflight.sh + mkdir -p $(BUILD_PREFLIGHT) || true + export OPENSHIFT_COHERENCE_COMPONENT_ID=$(OPENSHIFT_COHERENCE_COMPONENT_ID) \ + && export SUBMIT_RESULTS=$(SUBMIT_RESULTS) \ + && export REDHAT_EXAMPLE_IMAGE=$(REDHAT_EXAMPLE_IMAGE) \ + && $(SCRIPTS_DIR)/openshift/run-coherence-preflight.sh + # ====================================================================================================================== # Targets to run various tests # ====================================================================================================================== @@ -2667,10 +2718,10 @@ ifneq ("$(OPERATOR_RELEASE_REGISTRY)","$(OPERATOR_IMAGE_REGISTRY)") $(DOCKER_CMD) tag $(OPERATOR_IMAGE_AMD) $(OPERATOR_RELEASE_AMD) endif chmod +x $(SCRIPTS_DIR)/buildah/run-buildah.sh - export OPERATOR_IMAGE=$(OPERATOR_RELEASE_IMAGE) \ - && export OPERATOR_IMAGE_AMD=$(OPERATOR_RELEASE_AMD) \ - && export OPERATOR_IMAGE_ARM=$(OPERATOR_RELEASE_ARM) \ - && export OPERATOR_IMAGE_REGISTRY=$(OPERATOR_RELEASE_REGISTRY) \ + export IMAGE_NAME=$(OPERATOR_RELEASE_IMAGE) \ + && export IMAGE_NAME_AMD=$(OPERATOR_RELEASE_AMD) \ + && export IMAGE_NAME_ARM=$(OPERATOR_RELEASE_ARM) \ + && export IMAGE_NAME_REGISTRY=$(OPERATOR_RELEASE_REGISTRY) \ && export VERSION=$(VERSION) \ && export REVISION=$(GITCOMMIT) \ && export NO_DOCKER_DAEMON=$(NO_DOCKER_DAEMON) \ @@ -2692,10 +2743,10 @@ ifneq ("$(OPERATOR_RELEASE_REGISTRY)","$(OPERATOR_IMAGE_REGISTRY)") $(DOCKER_CMD) tag $(PREV_OPERATOR_IMAGE_AMD) $(PREV_OPERATOR_RELEASE_AMD) endif chmod +x $(SCRIPTS_DIR)/buildah/run-buildah.sh - export OPERATOR_IMAGE=$(PREV_OPERATOR_RELEASE_IMAGE) \ - && export OPERATOR_IMAGE_AMD=$(PREV_OPERATOR_RELEASE_AMD) \ - && export OPERATOR_IMAGE_ARM=$(PREV_OPERATOR_RELEASE_ARM) \ - && export OPERATOR_IMAGE_REGISTRY=$(PREV_OPERATOR_RELEASE_REGISTRY) \ + export IMAGE_NAME=$(PREV_OPERATOR_RELEASE_IMAGE) \ + && export IMAGE_NAME_AMD=$(PREV_OPERATOR_RELEASE_AMD) \ + && export IMAGE_NAME_ARM=$(PREV_OPERATOR_RELEASE_ARM) \ + && export IMAGE_NAME_REGISTRY=$(PREV_OPERATOR_RELEASE_REGISTRY) \ && export VERSION=$(PREV_VERSION) \ && export REVISION=$(GITCOMMIT) \ && export NO_DOCKER_DAEMON=$(NO_DOCKER_DAEMON) \ @@ -2706,8 +2757,7 @@ endif # Push the Operator JIB Test Docker images # ---------------------------------------------------------------------------------------------------------------------- .PHONY: push-test-images -push-test-images: - $(DOCKER_CMD) push $(PUSH_ARGS) $(TEST_APPLICATION_IMAGE) +push-test-images: push-basic-test-image $(DOCKER_CMD) push $(PUSH_ARGS) $(TEST_APPLICATION_IMAGE_CLIENT) $(DOCKER_CMD) push $(PUSH_ARGS) $(TEST_APPLICATION_IMAGE_HELIDON) $(DOCKER_CMD) push $(PUSH_ARGS) $(TEST_APPLICATION_IMAGE_HELIDON_2) @@ -2721,6 +2771,19 @@ ifneq (true,$(SKIP_SPRING_CNBP)) $(DOCKER_CMD) push $(PUSH_ARGS) $(TEST_APPLICATION_IMAGE_SPRING_CNBP_2) endif +.PHONY: push-basic-test-image +push-basic-test-image: + chmod +x $(SCRIPTS_DIR)/buildah/run-buildah.sh + export IMAGE_NAME=$(TEST_APPLICATION_IMAGE) \ + export IMAGE_NAME_AMD=$(TEST_APPLICATION_IMAGE)-amd64 \ + export IMAGE_NAME_ARM=$(TEST_APPLICATION_IMAGE)-arm64 \ + && export IMAGE_NAME_REGISTRY=$(OPERATOR_RELEASE_REGISTRY) \ + && export VERSION=$(VERSION) \ + && export REVISION=$(GITCOMMIT) \ + && export NO_DOCKER_DAEMON=$(NO_DOCKER_DAEMON) \ + && export DOCKER_CMD=$(DOCKER_CMD) \ + && $(SCRIPTS_DIR)/buildah/run-buildah.sh PUSH + # ---------------------------------------------------------------------------------------------------------------------- # Push the Operator Test images to ttl.sh # ---------------------------------------------------------------------------------------------------------------------- diff --git a/hack/buildah/build-coherence-images.sh b/hack/buildah/build-coherence-images.sh new file mode 100755 index 000000000..a6d6c1efa --- /dev/null +++ b/hack/buildah/build-coherence-images.sh @@ -0,0 +1,282 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2020, 2025, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# + +# --------------------------------------------------------------------------- +# This script uses Buildah to build a multi-architecture Coherence image. +# The architectures built are linux/amd64 and linux/arm64. +# The images are pushed to the local Docker daemon unless NO_DAEMON=true. +# --------------------------------------------------------------------------- +set -x -e + +BASEDIR=$(dirname "$0") + +if [ "${PROJECT_ROOT}" == "" ] +then + PROJECT_ROOT="${BASEDIR}" +fi + +# Ensure the IMAGE_NAME has been set - this is the name of the image to build +if [ "${IMAGE_NAME}" == "" ] +then + echo "ERROR: No IMAGE_NAME environment variable has been set" + exit 1 +fi +# Ensure the AMD_BASE_IMAGE has been set - this is the name of the base image for amd64 +if [ "${AMD_BASE_IMAGE}" == "" ] +then + echo "ERROR: No AMD_BASE_IMAGE environment variable has been set" + exit 1 +fi +# Ensure the ARM_BASE_IMAGE has been set - this is the name of the base image for arm64 +if [ "${ARM_BASE_IMAGE}" == "" ] +then + echo "ERROR: No ARM_BASE_IMAGE environment variable has been set" + exit 1 +fi + +# Ensure there is a default architecture - if not set we assume amd64 +if [ "${IMAGE_ARCH}" == "" ] +then + IMAGE_ARCH="amd64" +fi + +# Ensure there is a main class set +if [ "${MAIN_CLASS}" == "" ] +then + MAIN_CLASS=com.tangosol.net.Coherence +fi + +# Ensure there is an extend port set +if [ "${PORT_EXTEND}" == "" ] +then + PORT_EXTEND=20000 +fi + +# Ensure there is a concurrent extend port set +if [ "${PORT_CONCURRENT_EXTEND}" == "" ] +then + PORT_CONCURRENT_EXTEND=20001 +fi + +# Ensure there is a gRPC port set +if [ "${PORT_GRPC}" == "" ] +then + PORT_GRPC=1408 +fi + +# Ensure there is a management port set +if [ "${PORT_MANAGEMENT}" == "" ] +then + PORT_MANAGEMENT=30000 +fi + +# Ensure there is a metrics port set +if [ "${PORT_METRICS}" == "" ] +then + PORT_METRICS=9612 +fi + +# Ensure there is a health port set +if [ "${PORT_HEALTH}" == "" ] +then + PORT_HEALTH=6676 +fi + +# we must use docker format to use health checks +export BUILDAH_FORMAT=docker + +# Build the entrypoint command line. +ENTRY_POINT="java" + +CLASSPATH="/coherence/ext/conf:/coherence/ext/lib/*:/app/resources:/app/classes:/app/libs/*" + +DESCR="Oracle Coherence is a scalable, fault-tolerant, cloud-ready, distributed platform for building distributed applications and reliably storing data." + +IMAGE_PATH="" +LABEL_JAVA_VERSION="" +LABEL_JAVA_SPEC_VERSION="" + +# The command line +CMD="" +CMD="${CMD} -cp ${CLASSPATH}" +CMD="${CMD} -XshowSettings:all" +CMD="${CMD} -XX:+PrintCommandLineFlags" +CMD="${CMD} -XX:+PrintFlagsFinal" +CMD="${CMD} -Djava.net.preferIPv4Stack=true" +CMD="${CMD} @/args/jvm-args.txt" + +# The health check command line +HEALTH_CMD="" +HEALTH_CMD="${HEALTH_CMD} -cp ${CLASSPATH}" +HEALTH_CMD="${HEALTH_CMD} com.tangosol.util.HealthCheckClient" +HEALTH_CMD="${HEALTH_CMD} http://127.0.0.1:${PORT_HEALTH}/ready" + +# Build the environment variable options +ENV_VARS="" +ENV_VARS="${ENV_VARS} -e COHERENCE_WKA=localhost" +ENV_VARS="${ENV_VARS} -e COHERENCE_EXTEND_PORT=${PORT_EXTEND}" +ENV_VARS="${ENV_VARS} -e COHERENCE_CONCURRENT_EXTEND_PORT=${PORT_CONCURRENT_EXTEND}" +ENV_VARS="${ENV_VARS} -e COHERENCE_GRPC_ENABLED=true" +ENV_VARS="${ENV_VARS} -e COHERENCE_GRPC_SERVER_PORT=${PORT_GRPC}" +ENV_VARS="${ENV_VARS} -e COHERENCE_MANAGEMENT_HTTP=all" +ENV_VARS="${ENV_VARS} -e COHERENCE_MANAGEMENT_HTTP_PORT=${PORT_MANAGEMENT}" +ENV_VARS="${ENV_VARS} -e COHERENCE_METRICS_HTTP_ENABLED=true" +ENV_VARS="${ENV_VARS} -e COHERENCE_METRICS_HTTP_PORT=${PORT_METRICS}" +ENV_VARS="${ENV_VARS} -e COHERENCE_HEALTH_HTTP_PORT=${PORT_HEALTH}" +ENV_VARS="${ENV_VARS} -e COHERENCE_TTL=0" +ENV_VARS="${ENV_VARS} -e COH_MAIN_CLASS=${MAIN_CLASS}" +ENV_VARS="${ENV_VARS} -e JAEGER_SAMPLER_TYPE=const" +ENV_VARS="${ENV_VARS} -e JAEGER_SAMPLER_PARAM=0" +ENV_VARS="${ENV_VARS} -e JAEGER_SERVICE_NAME=coherence" +ENV_VARS="${ENV_VARS} -e LANG=en_US.UTF-8" + +# Build the exposed port list +PORT_LIST="" +PORT_LIST="${PORT_LIST} -p ${PORT_EXTEND}" +PORT_LIST="${PORT_LIST} -p ${PORT_CONCURRENT_EXTEND}" +PORT_LIST="${PORT_LIST} -p ${PORT_GRPC}" +PORT_LIST="${PORT_LIST} -p ${PORT_MANAGEMENT}" +PORT_LIST="${PORT_LIST} -p ${PORT_METRICS}" +PORT_LIST="${PORT_LIST} -p ${PORT_HEALTH}" + +# The image creation date +CREATED=$(date) + +# Common image builder function +# param 1: the image architecture, e.g. amd64 or arm64 +# param 2: the image o/s e.g. linux +# param 3: the base image +# param 4: the image name +common_image(){ + # make sure the old container is removed + buildah rm "container-${1}" || true + + # Create the container from the base image, setting the architecture and O/S + # The "buildah from" command will pull the base image if not present, this will + # be retried a maximum of five times as there are occasional timeouts for large + # base images such as Graal + exitCode=0 + for i in $(seq 1 5); do buildah from --arch "${1}" --os "${2}" --name "container-${1}" "${3}" \ + && exitCode=0 && break || exitCode=$? \ + && echo "The command 'buildah from...' failed. Attempt ${i} of 5" \ + && sleep 10; done; + + if [ ${exitCode} != 0 ]; then + exit 1 + fi + + # Add the configuration, entrypoint, ports, env-vars etc... + buildah config --healthcheck-start-period 30s --healthcheck-interval 60s --healthcheck "CMD ${ENTRY_POINT} ${HEALTH_CMD}" "container-${1}" + + buildah config --arch "${1}" --os "${2}" \ + --entrypoint "[\"${ENTRY_POINT}\"]" --cmd "${CMD} ${MAIN_CLASS}" \ + ${ENV_VARS} ${ENV_VARS_JAVA_HOME} ${PORT_LIST} \ + --annotation "org.opencontainers.image.created=${CREATED}" \ + --annotation "org.opencontainers.image.url=https://github.com/oracle/coherence/pkgs/container/coherence-ce" \ + --annotation "org.opencontainers.image.version=${COHERENCE_VERSION}" \ + --annotation "org.opencontainers.image.source=http://github.com/oracle/coherence" \ + --annotation "org.opencontainers.image.vendor=Oracle" \ + --annotation "org.opencontainers.image.title=Oracle Coherence CE version ${COHERENCE_VERSION}" \ + --annotation "org.opencontainers.image.revision=${COHERENCE_VERSION}" \ + --annotation "org.opencontainers.image.licenses=UPL-1.0" \ + --annotation "org.opencontainers.image.authors=To contact the authors use this link https://github.com/oracle/coherence/discussions" \ + --annotation "org.opencontainers.image.description"="${DESCR}" \ + --label "org.opencontainers.image.created=${CREATED}" \ + --label "org.opencontainers.image.url=https://github.com/oracle/coherence/pkgs/container/coherence-ce" \ + --label "org.opencontainers.image.version=${COHERENCE_VERSION}" \ + --label "org.opencontainers.image.source=http://github.com/oracle/coherence" \ + --label "org.opencontainers.image.vendor=Oracle" \ + --label "org.opencontainers.image.title=Oracle Coherence CE version ${COHERENCE_VERSION}" \ + --label "org.opencontainers.image.licenses=UPL-1.0" \ + --label "org.opencontainers.image.authors=To contact the authors use this link https://github.com/oracle/coherence/discussions" \ + --label "name"="Oracle Coherence" \ + --label "vendor"="Oracle" \ + --label "version"="${COHERENCE_VERSION}" \ + --label "release"="${COHERENCE_VERSION}" \ + --label "maintainer"="Oracle Coherence Engineering Team" \ + --label "summary"="Oracle Coherence CE version ${COHERENCE_VERSION}" \ + --label "description"="Oracle Coherence CE version ${COHERENCE_VERSION}" \ + "container-${1}" + + # Write JIB compatible main class file + echo "${MAIN_CLASS}" >> "${PROJECT_ROOT}/java/operator-test/target/docker/app/jib-main-class-file" + + # Copy files into the container + buildah copy "container-${1}" "${PROJECT_ROOT}/java/operator-test/target/docker/app" /app + buildah copy "container-${1}" "${PROJECT_ROOT}/java/operator-test/target/docker/args" /args + buildah copy "container-${1}" "${PROJECT_ROOT}/java/operator-test/target/*.jar" /app/libs + + if [ -d "${PROJECT_ROOT}/java/operator-test/target/docker/licenses" ]; then + buildah copy "container-${1}" "${PROJECT_ROOT}/java/operator-test/target/docker/licenses" /licenses + fi + + # Commit the container to an image + buildah commit "container-${1}" "coherence:${1}" + buildah tag "coherence:${1}" "${4}" + + # Export the image to the Docker daemon unless NO_DAEMON is true + if [ "${NO_DOCKER_DAEMON}" != "true" ] + then + buildah push -f v2s2 "coherence:${1}" "docker-daemon:${4}" + echo "Pushed ${2}/${1} image ${4} to Docker daemon" + fi +} + +buildah version + +if [ "${OCR_DOCKER_USERNAME}" != "" ] && [ "${OCR_DOCKER_USERNAME}" != "" ] +then + echo "Login to OCR" + buildah login -u "${OCR_DOCKER_USERNAME}" -p "${OCR_DOCKER_PASSWORD}" "${OCR_DOCKER_SERVER}" +fi + +if [ "${GHCR_USERNAME}" != "" ] && [ "${GHCR_PASSWORD}" != "" ] +then + echo "Login to GitHub container registry" + buildah login -u "${GHCR_USERNAME}" -p "${GHCR_PASSWORD}" ghcr.io +fi + +if [ "${REDHAT_REGISTRY_USERNAME}" != "" ] && [ "${REDHAT_REGISTRY_PASSWORD}" != "" ] +then + echo "Login to Red Hat container registry" + buildah login -u "${REDHAT_REGISTRY_USERNAME}" -p "${REDHAT_REGISTRY_PASSWORD}" registry.redhat.io +fi + +# Build the amd64 image +if [ "${BUILD_ALL_IMAGES}" == "true" ] || [ "${IMAGE_ARCH}" == "amd64" ] +then + common_image amd64 linux "${AMD_BASE_IMAGE}" "${IMAGE_NAME}-amd64" +fi + +# Build the arm64 image +if [ "${BUILD_ALL_IMAGES}" == "true" ] || [ "${IMAGE_ARCH}" == "arm64" ] +then + common_image arm64 linux "${ARM_BASE_IMAGE}" "${IMAGE_NAME}-arm64" +fi + +# Push the relevant image to the docker daemon base on the build machine's o/s architecture +if [ "${NO_DOCKER_DAEMON}" != "true" ] +then + buildah push -f v2s2 "coherence:${IMAGE_ARCH}" "docker-daemon:${IMAGE_NAME}" + echo "Pushed linux/${IMAGE_ARCH} image ${IMAGE_NAME} to Docker daemon" +else + buildah tag "coherence:${IMAGE_ARCH}" "${IMAGE_NAME}" + if [ "${PODMAN_IMPORT}" == "true" ] + then + TAR_NAME="${BASEDIR}/java/operator-test/target/coherence-image.tar" + buildah push -f v2s2 -q "coherence:${IMAGE_ARCH}" "oci-archive:${TAR_NAME}:${IMAGE_NAME}" + podman import "${TAR_NAME}" "${IMAGE_NAME}" + fi +fi + +# Clean-up +buildah rm "container-amd64" || true +buildah rmi "coherence:amd64" || true +buildah rm "container-arm64" || true +buildah rmi "coherence:arm64" || true + + diff --git a/hack/buildah/push-images.sh b/hack/buildah/push-images.sh index 2fd53aa9d..c2beeafa0 100755 --- a/hack/buildah/push-images.sh +++ b/hack/buildah/push-images.sh @@ -8,37 +8,51 @@ set -x -e -v buildah version -if [ "${OPERATOR_IMAGE_REGISTRY}" != "" ] && [ "${REGISTRY_USERNAME}" != "" ] && [ "${REGISTRY_PASSWORD}" != "" ] +if [ "${IMAGE_NAME_REGISTRY}" != "" ] && [ "${REGISTRY_USERNAME}" != "" ] && [ "${REGISTRY_PASSWORD}" != "" ] then - buildah login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" "${OPERATOR_IMAGE_REGISTRY}" + buildah login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" "${IMAGE_NAME_REGISTRY}" +fi + +if [ "${IMAGE_NAME_AMD}" == "" ] +then + IMAGE_NAME_AMD="${IMAGE_NAME}-amd64" +fi + +if [ "${IMAGE_NAME_ARM}" == "" ] +then + IMAGE_NAME_ARM="${IMAGE_NAME}-arm64" fi if [ "${NO_DOCKER_DAEMON}" != "true" ] then - buildah pull "docker-daemon:${OPERATOR_IMAGE_AMD}" - buildah pull "docker-daemon:${OPERATOR_IMAGE_ARM}" + buildah pull "docker-daemon:${IMAGE_NAME_AMD}" + buildah pull "docker-daemon:${IMAGE_NAME_ARM}" fi -buildah rmi "${OPERATOR_IMAGE}" || true -buildah manifest rm "${OPERATOR_IMAGE}" || true +buildah rmi "${IMAGE_NAME}" || true +buildah manifest rm "${IMAGE_NAME}" || true + buildah manifest create \ --annotation org.opencontainers.image.source=https://github.com/oracle/coherence-operator \ --annotation org.opencontainers.image.licenses="UPL-1.0" \ --annotation org.opencontainers.image.version="${VERSION}" \ --annotation org.opencontainers.image.revision="${REVISION}" \ - "${OPERATOR_IMAGE}" + "${IMAGE_NAME}" + buildah manifest add --arch amd64 --os linux \ --annotation org.opencontainers.image.source=https://github.com/oracle/coherence-operator \ --annotation org.opencontainers.image.licenses="UPL-1.0" \ --annotation org.opencontainers.image.version="${VERSION}" \ --annotation org.opencontainers.image.revision="${REVISION}" \ - "${OPERATOR_IMAGE}" "${OPERATOR_IMAGE_AMD}" + "${IMAGE_NAME}" "${IMAGE_NAME_AMD}" + buildah manifest add --arch arm64 --os linux \ --annotation org.opencontainers.image.source=https://github.com/oracle/coherence-operator \ --annotation "org.opencontainers.image.licenses"="UPL-1.0" \ --annotation org.opencontainers.image.version="${VERSION}" \ --annotation org.opencontainers.image.revision="${REVISION}" \ - "${OPERATOR_IMAGE}" "${OPERATOR_IMAGE_ARM}" -buildah manifest inspect "${OPERATOR_IMAGE}" + "${IMAGE_NAME}" "${IMAGE_NAME_ARM}" + +buildah manifest inspect "${IMAGE_NAME}" -buildah manifest push --all -f v2s2 "${OPERATOR_IMAGE}" "docker://${OPERATOR_IMAGE}" +buildah manifest push --all -f v2s2 "${IMAGE_NAME}" "docker://${IMAGE_NAME}" diff --git a/hack/buildah/run-buildah.sh b/hack/buildah/run-buildah.sh index ee7d11560..5d3a3aef1 100755 --- a/hack/buildah/run-buildah.sh +++ b/hack/buildah/run-buildah.sh @@ -14,21 +14,21 @@ set -x -e BASEDIR=$(dirname "$0") -# Ensure the OPERATOR_IMAGE has been set - this is the name of the image to build -if [ "${OPERATOR_IMAGE}" == "" ] +# Ensure the IMAGE_NAME has been set - this is the name of the image to build +if [ "${IMAGE_NAME}" == "" ] then - echo "ERROR: No OPERATOR_IMAGE environment variable has been set" + echo "ERROR: No IMAGE_NAME environment variable has been set" exit 1 fi -if [ "${OPERATOR_IMAGE_AMD}" == "" ] +if [ "${IMAGE_NAME_AMD}" == "" ] then - OPERATOR_IMAGE_AMD="${OPERATOR_IMAGE}-amd64" + IMAGE_NAME_AMD="${IMAGE_NAME}-amd64" fi -if [ "${OPERATOR_IMAGE_ARM}" == "" ] +if [ "${IMAGE_NAME_ARM}" == "" ] then - OPERATOR_IMAGE_AMD="${OPERATOR_IMAGE}-arm64" + IMAGE_NAME_AMD="${IMAGE_NAME}-arm64" fi ARGS= @@ -36,6 +36,9 @@ ARGS= if [ "$1" == "PUSH" ] then SCRIPT_NAME="${BASEDIR}/push-images.sh" +elif [ "$1" == "BUILD" ] +then + SCRIPT_NAME="${BASEDIR}/build-coherence-images.sh" elif [ "$1" == "EXEC" ] then SCRIPT_NAME= @@ -48,7 +51,7 @@ then fi BUILDAH="" -if [ "${LOCAL_BUILDAH}" == "true" ] +if [ "${LOCAL_BUILDAH}" != "false" ] then BUILDAH=$(which buildah || true) fi @@ -100,20 +103,37 @@ else fi fi - $DOCKER_CMD run --rm ${ARGS} -v "${BASEDIR}:${BASEDIR}" \ + if [ "${PROJECT_ROOT}" == "" ] + then + PROJECT_ROOT="${BASEDIR}" + fi + + $DOCKER_CMD run --rm ${ARGS} -v "${PROJECT_ROOT}:${PROJECT_ROOT}" \ -v ${DOCKER_HOST}:${DOCKER_HOST} \ --privileged --network host \ + -e PROJECT_ROOT="${PROJECT_ROOT}" \ -e VERSION="${VERSION}" \ -e REVISION="${REVISION}" \ - -e OPERATOR_IMAGE="${OPERATOR_IMAGE}" \ - -e OPERATOR_IMAGE_AMD="${OPERATOR_IMAGE_AMD}" \ - -e OPERATOR_IMAGE_ARM="${OPERATOR_IMAGE_ARM}" \ + -e OCR_DOCKER_USERNAME="${OCR_DOCKER_USERNAME}" \ + -e OCR_DOCKER_USERNAME="${OCR_DOCKER_USERNAME}" \ + -e OCR_DOCKER_SERVER="${OCR_DOCKER_SERVER}" \ + -e REDHAT_REGISTRY_USERNAME="${REDHAT_REGISTRY_USERNAME}" \ + -e REDHAT_REGISTRY_PASSWORD="${REDHAT_REGISTRY_PASSWORD}" \ + -e COHERENCE_VERSION="${COHERENCE_VERSION}" \ + -e IMAGE_NAME="${IMAGE_NAME}" \ + -e AMD_BASE_IMAGE="${AMD_BASE_IMAGE}" \ + -e IMAGE_NAME_AMD="${IMAGE_NAME_AMD}" \ + -e ARM_BASE_IMAGE="${ARM_BASE_IMAGE}" \ + -e IMAGE_NAME_ARM="${IMAGE_NAME_ARM}" \ + -e IMAGE_ARCH="${IMAGE_ARCH}" \ + -e MAIN_CLASS="${MAIN_CLASS}" \ -e PODMAN_IMPORT="${PODMAN_IMPORT}" \ -e DOCKER_HOST="${DOCKER_HOST}" \ -e NO_DOCKER_DAEMON="${NO_DOCKER_DAEMON}" \ - -e OPERATOR_IMAGE_REGISTRY="${OPERATOR_IMAGE_REGISTRY}" \ + -e IMAGE_NAME_REGISTRY="${IMAGE_NAME_REGISTRY}" \ -e REGISTRY_USERNAME="${REGISTRY_USERNAME}" \ -e REGISTRY_PASSWORD="${REGISTRY_PASSWORD}" \ + -e BUILD_ALL_IMAGES="${BUILD_ALL_IMAGES}" \ -e HTTP_PROXY="${HTTP_PROXY}" -e HTTPS_PROXY="${HTTPS_PROXY}" -e NO_PROXY="${NO_PROXY}" \ -e http_proxy="${http_proxy}" -e https_proxy="${https_proxy}" -e no_proxy="${no_proxy}" \ --name buildah \ diff --git a/hack/openshift/run-coherence-preflight.sh b/hack/openshift/run-coherence-preflight.sh new file mode 100755 index 000000000..da54ca0fc --- /dev/null +++ b/hack/openshift/run-coherence-preflight.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2020, 2025, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# + +ROOT_DIR=$(pwd) +BUILD_DIR="${ROOT_DIR}/build" +OUTPUT_DIR="${BUILD_DIR}/_output" + +mkdir -p "${OUTPUT_DIR}" || true + +if [ -z "${SUBMIT_RESULTS:-}" ]; then + SUBMIT_RESULTS=false +fi + +if [ -z "${REDHAT_EXAMPLE_IMAGE}" ]; then + echo "Error: REDHAT_EXAMPLE_IMAGE should be set to the name of the Red Hat Coherence image" + exit 1 +fi + +if [ "${SUBMIT_RESULTS}" = "true" ]; then + if [ -z "${OPENSHIFT_API_KEY:-}" ]; then + echo "Error: SUBMIT_RESULTS is set to 'true' but OPENSHIFT_API_KEY is not set" + exit 1 + fi + if [ -z "${OPENSHIFT_COHERENCE_COMPONENT_ID:-}" ]; then + OPENSHIFT_COHERENCE_COMPONENT_ID="68d28054a49e977fe49f4234" + fi + EXTRA_ARGS="--pyxis-api-token=${OPENSHIFT_API_KEY} --certification-component-id=${OPENSHIFT_COHERENCE_COMPONENT_ID}" +else + EXTRA_ARGS="" +fi + +echo "Running preflight on ${REDHAT_EXAMPLE_IMAGE}" + +PREFLIGHT_LOG="${OUTPUT_DIR}/preflight.log" +preflight check container --submit="${SUBMIT_RESULTS}" --logfile="${PREFLIGHT_LOG}" ${EXTRA_ARGS} ${REDHAT_EXAMPLE_IMAGE} diff --git a/java/operator-test/pom.xml b/java/operator-test/pom.xml index f35187cab..0c887b001 100644 --- a/java/operator-test/pom.xml +++ b/java/operator-test/pom.xml @@ -1,28 +1,26 @@ + ~ Copyright (c) 2020, 2025, Oracle and/or its affiliates. + ~ Licensed under the Universal Permissive License v 1.0 as shown at + ~ http://oss.oracle.com/licenses/upl. + --> - 4.0.0 + 4.0.0 - - com.oracle.coherence.kubernetes - operator-parent - ${revision} - ../pom.xml - + + com.oracle.coherence.kubernetes + operator-parent + ${revision} + ../pom.xml + - operator-test + operator-test - Oracle Coherence Kubernetes Operator Test - operator-test + Oracle Coherence Kubernetes Operator Test + operator-test @@ -36,41 +34,60 @@ - - - ${coherence.groupId} - coherence - - - ${coherence.groupId} - coherence-json - - - ${coherence.groupId} - coherence-grpc-proxy - - - ${coherence.groupId} - coherence-management - - + + + ${coherence.groupId} + coherence + + + ${coherence.groupId} + coherence-json + + + ${coherence.groupId} + coherence-grpc-proxy + + + + + + + com.google.cloud.tools + jib-maven-plugin + ${version.plugin.jib} + + + ${coherence.test.base.image} + + + com.oracle.coherence.k8s.testing.RestServer + OCI + + + - - - - com.google.cloud.tools - jib-maven-plugin - ${version.plugin.jib} - - - ${coherence.test.base.image} - - - com.oracle.coherence.k8s.testing.RestServer - OCI - - - - - + + + org.apache.maven.plugins + maven-assembly-plugin + + + docker + prepare-package + + single + + + docker + false + + src/assembly/image-assembly.xml + + false + + + + + + diff --git a/java/operator-test/src/assembly/image-assembly.xml b/java/operator-test/src/assembly/image-assembly.xml new file mode 100644 index 000000000..672473a6d --- /dev/null +++ b/java/operator-test/src/assembly/image-assembly.xml @@ -0,0 +1,42 @@ + + + + image + + dir + + + false + + + + + target/classes + app/classes + 755 + false + + + + src/main/args + args + 755 + true + + + + + + app/libs + 755 + 755 + false + false + + + diff --git a/java/operator-test/src/main/args/jvm-args.txt b/java/operator-test/src/main/args/jvm-args.txt new file mode 100644 index 000000000..e69de29bb