diff --git a/.github/workflows/flow-deploy-release-artifact.yaml b/.github/workflows/flow-deploy-release-artifact.yaml index 0cb292042..418d1b7c2 100644 --- a/.github/workflows/flow-deploy-release-artifact.yaml +++ b/.github/workflows/flow-deploy-release-artifact.yaml @@ -1,5 +1,5 @@ ## -# Copyright (C) 2023 Hedera Hashgraph, LLC +# Copyright (C) 2023-2024 Hedera Hashgraph, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -153,6 +153,14 @@ jobs: push: ${{ github.event.inputs.dry-run-enabled != 'true' }} tags: ghcr.io/${{ github.repository }}/ubi8-init-java17:${{ needs.prepare-release.outputs.version }} + - name: Build Docker Image (ubi8-init-java21) + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 + with: + context: docker/ubi8-init-java21 + platforms: linux/amd64, linux/arm64 + push: ${{ github.event.inputs.dry-run-enabled != 'true' }} + tags: ghcr.io/${{ github.repository }}/ubi8-init-java21:${{ needs.prepare-release.outputs.version }} + - name: Build Docker Image (kubectl-bats) uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 with: diff --git a/docker/ubi8-init-java21/Dockerfile b/docker/ubi8-init-java21/Dockerfile new file mode 100644 index 000000000..452828455 --- /dev/null +++ b/docker/ubi8-init-java21/Dockerfile @@ -0,0 +1,118 @@ +# +# Copyright (C) 2023 Hedera Hashgraph, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM registry.access.redhat.com/ubi8/ubi-init:latest +# Define Standard Environment Variables +ENV LC_ALL=C.UTF-8 + +# Define JDK Environment Variables +ENV JAVA_VERSION "jdk-21.0.1+12" +ENV JAVA_HOME /usr/local/java +ENV PATH ${JAVA_HOME}/bin:${PATH} + +# Define Application Environment Variables +ENV JAVA_HEAP_MIN="" +ENV JAVA_HEAP_MAX="" +ENV JAVA_OPTS="" +ENV JAVA_MAIN_CLASS "" +ENV JAVA_CLASS_PATH "" + +# Performance Tuning for Malloc +ENV MALLOC_ARENA_MAX 4 + +# Log Folder Name Override +ENV LOG_DIR_NAME "" + +RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && \ + /usr/bin/crb enable && \ + dnf -y install binutils libsodium openssl zlib readline tzdata gzip tar ca-certificates curl && \ + dnf clean all + +# Install Java 21 Adoptium JDK +RUN set -eux; \ + ARCH="$(objdump="$(command -v objdump)" && objdump --file-headers "$objdump" | awk -F '[:,]+[[:space:]]+' '$1 == "architecture" { print $2 }')"; \ + case "${ARCH}" in \ + aarch64|arm64) \ + ESUM='e184dc29a6712c1f78754ab36fb48866583665fa345324f1a79e569c064f95e9'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.1%2B12/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.1_12.tar.gz'; \ + ;; \ + amd64|i386:x86-64) \ + ESUM='1a6fa8abda4c5caed915cfbeeb176e7fbd12eb6b222f26e290ee45808b529aa1'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.1%2B12/OpenJDK21U-jdk_x64_linux_hotspot_21.0.1_12.tar.gz'; \ + ;; \ + ppc64el|powerpc:common64) \ + ESUM='9574828ef3d735a25404ced82e09bf20e1614f7d6403956002de9cfbfcb8638f'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.1%2B12/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.1_12.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + curl -LfsSo /tmp/openjdk.tar.gz ${BINARY_URL}; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p /usr/local/java; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "/usr/local/java" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz /usr/local/java/lib/src.zip; + +RUN dnf -y install sudo && \ + echo >> /etc/sudoers && \ + echo "%hedera ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +# Configure the standard user account +RUN groupadd --gid 2000 hedera && \ + useradd --no-user-group --create-home --uid 2000 --gid 2000 --shell /bin/bash hedera && \ + mkdir -p /opt/hgcapp && \ + chown -R hedera:hedera /opt/hgcapp + +# Create Application Folders +RUN mkdir -p "/opt/hgcapp" && \ + mkdir -p "/opt/hgcapp/accountBalances" && \ + mkdir -p "/opt/hgcapp/eventsStreams" && \ + mkdir -p "/opt/hgcapp/recordStreams" && \ + mkdir -p "/opt/hgcapp/services-hedera" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data/apps" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data/config" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data/keys" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data/lib" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data/stats" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data/saved" && \ + mkdir -p "/opt/hgcapp/services-hedera/HapiApp2.0/data/upgrade" + +# Add the entrypoint script and systemd service file +ADD entrypoint.sh /etc/network-node/ +ADD network-node.service /usr/lib/systemd/system/ + +# Ensure proper file permissions +RUN chmod -R +x /etc/network-node/entrypoint.sh && \ + chown -R 2000:2000 /opt/hgcapp/ + +RUN mkdir -p /etc/network-node && \ + touch /etc/network-node/application.env && \ + chown -R 2000:2000 /etc/network-node + +# Expose TCP/UDP Port Definitions +EXPOSE 50111/tcp 50211/tcp 50212/tcp + +# Set Final Working Directory and User +WORKDIR "/opt/hgcapp" diff --git a/docker/ubi8-init-java21/build.gradle.kts b/docker/ubi8-init-java21/build.gradle.kts new file mode 100644 index 000000000..274cc63b5 --- /dev/null +++ b/docker/ubi8-init-java21/build.gradle.kts @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.palantir.docker") version "0.35.0" +} + +val repo = "ghcr.io" +val registry = "hashgraph/full-stack-testing" +val containerName = "ubi8-init-java21" +val appVersion = project.version.toString() + +docker { + name = "${repo}/${registry}/${containerName}:${appVersion}" + version = appVersion + files("entrypoint.sh", "network-node.service") + buildx(true) + if (!System.getenv("CI").isNullOrEmpty()) { + platform("linux/arm64", "linux/amd64") + push(true) + } else { + load(true) // loads the image into the local docker daemon, doesn't support multi-platform + } +} diff --git a/docker/ubi8-init-java21/entrypoint.sh b/docker/ubi8-init-java21/entrypoint.sh new file mode 100644 index 000000000..03a3d3116 --- /dev/null +++ b/docker/ubi8-init-java21/entrypoint.sh @@ -0,0 +1,112 @@ +#!/usr/bin/env bash + +######################################################################################################################## +# Copyright 2016-2022 Hedera Hashgraph, LLC # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +######################################################################################################################## + +set -eo pipefail + +SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "${SCRIPT_PATH}" || exit 64 + +if [[ -z "${JAVA_OPTS}" ]]; then + JAVA_OPTS="" +fi + +# Setup Heap Options +JAVA_HEAP_OPTS="" + +if [[ -n "${JAVA_HEAP_MIN}" ]]; then + JAVA_HEAP_OPTS="${JAVA_HEAP_OPTS} -Xms${JAVA_HEAP_MIN}" +fi + +if [[ -n "${JAVA_HEAP_MAX}" ]]; then + JAVA_HEAP_OPTS="${JAVA_HEAP_OPTS} -Xmx${JAVA_HEAP_MAX}" +fi + +# Setup Main Class +[[ -z "${JAVA_MAIN_CLASS}" ]] && JAVA_MAIN_CLASS="com.swirlds.platform.Browser" + +# Setup Classpath +JCP_OVERRIDDEN="false" +if [[ -z "${JAVA_CLASS_PATH}" ]]; then + JAVA_CLASS_PATH="data/lib/*" +else + JCP_OVERRIDDEN="true" +fi + +if [[ "${JCP_OVERRIDDEN}" != true && "${JAVA_MAIN_CLASS}" != "com.swirlds.platform.Browser" ]]; then + JAVA_CLASS_PATH="${JAVA_CLASS_PATH}:data/apps/*" +fi + +# Override Log Directory Name (if provided) +LOG_DIR_NAME="${LOG_DIR_NAME:-output}" + +# Ensure the log directory exists +if [[ ! -d "${SCRIPT_PATH}/${LOG_DIR_NAME}" ]]; then + mkdir -p "${SCRIPT_PATH}/${LOG_DIR_NAME}" +fi + +cat <>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> BEGIN USER IDENT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +id +echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< END USER IDENT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" +echo + +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> BEGIN JAVA VERSION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +/usr/bin/env java -version +echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< END JAVA VERSION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" +echo + +set +e +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> BEGIN NODE OUTPUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +/usr/bin/env java ${JAVA_HEAP_OPTS} ${JAVA_OPTS} -cp "${JAVA_CLASS_PATH}" "${JAVA_MAIN_CLASS}" +EC="${?}" +echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< END NODE OUTPUT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + +echo +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> BEGIN EXIT CODE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +printf "Process Exit Code: %s\n" "${EC}" +echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< END EXIT CODE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + +printf "\n\n#### Hedera Services Node Software Stopped ####\n\n" diff --git a/docker/ubi8-init-java21/network-node.service b/docker/ubi8-init-java21/network-node.service new file mode 100644 index 000000000..634d70aa9 --- /dev/null +++ b/docker/ubi8-init-java21/network-node.service @@ -0,0 +1,18 @@ +[Unit] +Description=Hedera Network Node +After=network.target + +[Service] +Type=simple +Restart=no +User=hedera +Group=hedera + +PassEnvironment=JAVA_HOME JAVA_OPTS JAVA_HEAP_MIN JAVA_HEAP_MAX PATH APP_HOME +EnvironmentFile=/etc/network-node/application.env + +WorkingDirectory=/opt/hgcapp/services-hedera/HapiApp2.0 +ExecStart=/usr/bin/bash /etc/network-node/entrypoint.sh + +[Install] +WantedBy=multi-user.target diff --git a/settings.gradle.kts b/settings.gradle.kts index ca93da577..cb243c70c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Hedera Hashgraph, LLC + * Copyright (C) 2023-2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,8 @@ include(":docker-ubi8-init-dind", "docker/ubi8-init-dind") include(":docker-ubi8-init-java17", "docker/ubi8-init-java17") +include(":docker-ubi8-init-java21", "docker/ubi8-init-java21") + include(":fullstack-bom", "fullstack-core/fullstack-bom") include(":fullstack-alerting-api", "fullstack-core/fullstack-alerting-api")