From 548ce9a1fe57fcca99bd8b15851c6bc0be4473cd Mon Sep 17 00:00:00 2001 From: George Adams Date: Wed, 13 Mar 2024 14:00:15 +0000 Subject: [PATCH] add riscv64 support --- 21/jdk/debian/sid-slim/Dockerfile | 94 +++++++++++++++++++ 21/jdk/debian/sid-slim/entrypoint.sh | 30 ++++++ 21/jre/debian/sid-slim/Dockerfile | 87 +++++++++++++++++ 21/jre/debian/sid-slim/entrypoint.sh | 30 ++++++ config/hotspot.yml | 7 ++ docker_templates/debian.Dockerfile.j2 | 43 +++++++++ docker_templates/partials/arch-variable.j2 | 2 +- docker_templates/scripts/entrypoint.debian.sh | 1 + dockerhub_doc_config_update.sh | 11 ++- generate_dockerfiles.py | 8 +- 10 files changed, 307 insertions(+), 6 deletions(-) create mode 100644 21/jdk/debian/sid-slim/Dockerfile create mode 100755 21/jdk/debian/sid-slim/entrypoint.sh create mode 100644 21/jre/debian/sid-slim/Dockerfile create mode 100755 21/jre/debian/sid-slim/entrypoint.sh create mode 100644 docker_templates/debian.Dockerfile.j2 create mode 120000 docker_templates/scripts/entrypoint.debian.sh diff --git a/21/jdk/debian/sid-slim/Dockerfile b/21/jdk/debian/sid-slim/Dockerfile new file mode 100644 index 000000000..7aa0e5277 --- /dev/null +++ b/21/jdk/debian/sid-slim/Dockerfile @@ -0,0 +1,94 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS DOCKERFILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# 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 +# +# https://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 debian:sid-slim + +ENV JAVA_HOME /opt/java/openjdk +ENV PATH $JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + wget \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION jdk-21.0.2+13 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64|i386:x86-64) \ + ESUM='454bebb2c9fe48d981341461ffb6bf1017c7b7c6e15c6b0c29b959194ba3aaa5'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='791a37ddb040e1a02bbfc61abfbc7e7321431a28054c9ac59ba1738fd5320b02'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_riscv64_linux_hotspot_21.0.2_13.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/debian/sid-slim/entrypoint.sh b/21/jdk/debian/sid-slim/entrypoint.sh new file mode 100755 index 000000000..dfcf546f9 --- /dev/null +++ b/21/jdk/debian/sid-slim/entrypoint.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Sheband needs to be `bash`, see https://github.com/adoptium/containers/issues/415 for details + +set -e + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates)" ]; then + cp -a /certificates/* /usr/local/share/ca-certificates/ + fi + + CACERT=$JAVA_HOME/lib/security/cacerts + + # JDK8 puts its JRE in a subdirectory + if [ -f "$JAVA_HOME/jre/lib/security/cacerts" ]; then + CACERT=$JAVA_HOME/jre/lib/security/cacerts + fi + + # OpenJDK images used to create a hook for `update-ca-certificates`. Since we are using an entrypoint anyway, we + # might as well just generate the truststore and skip the hooks. + update-ca-certificates + + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$CACERT" +fi + +exec "$@" diff --git a/21/jre/debian/sid-slim/Dockerfile b/21/jre/debian/sid-slim/Dockerfile new file mode 100644 index 000000000..f133a3463 --- /dev/null +++ b/21/jre/debian/sid-slim/Dockerfile @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS DOCKERFILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# 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 +# +# https://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 debian:sid-slim + +ENV JAVA_HOME /opt/java/openjdk +ENV PATH $JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + wget \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION jdk-21.0.2+13 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64|i386:x86-64) \ + ESUM='51141204fe01a9f9dd74eab621d5eca7511eac67315c9975dbde5f2625bdca55'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jre_x64_linux_hotspot_21.0.2_13.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='efdeca282553229aa20d909ab9f5fb14eee52b56067a5598e6c649ef5f99a63d'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jre_riscv64_linux_hotspot_21.0.2_13.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/debian/sid-slim/entrypoint.sh b/21/jre/debian/sid-slim/entrypoint.sh new file mode 100755 index 000000000..dfcf546f9 --- /dev/null +++ b/21/jre/debian/sid-slim/entrypoint.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Sheband needs to be `bash`, see https://github.com/adoptium/containers/issues/415 for details + +set -e + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates)" ]; then + cp -a /certificates/* /usr/local/share/ca-certificates/ + fi + + CACERT=$JAVA_HOME/lib/security/cacerts + + # JDK8 puts its JRE in a subdirectory + if [ -f "$JAVA_HOME/jre/lib/security/cacerts" ]; then + CACERT=$JAVA_HOME/jre/lib/security/cacerts + fi + + # OpenJDK images used to create a hook for `update-ca-certificates`. Since we are using an entrypoint anyway, we + # might as well just generate the truststore and skip the hooks. + update-ca-certificates + + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$CACERT" +fi + +exec "$@" diff --git a/config/hotspot.yml b/config/hotspot.yml index 32c819395..27e139d2b 100644 --- a/config/hotspot.yml +++ b/config/hotspot.yml @@ -29,6 +29,13 @@ configurations: deprecated: 20 os: ubuntu + # sid -- Debian x.y Unstable + - directory: debian/sid-slim + architectures: [riscv64, x64] + image: debian:sid-slim + starts_from: 21 + os: debian + - directory: centos architectures: [aarch64, ppc64le, x64] image: centos:7 diff --git a/docker_templates/debian.Dockerfile.j2 b/docker_templates/debian.Dockerfile.j2 new file mode 100644 index 000000000..365f11a80 --- /dev/null +++ b/docker_templates/debian.Dockerfile.j2 @@ -0,0 +1,43 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + wget \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ +{% include 'partials/binutils.j2' -%} + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION {{ java_version }} + +{% include 'partials/multi-arch-install.j2' %} \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + {% if version|int >= 11 -%} + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; +{% else -%} + ldconfig; +{% endif %} +{% include 'partials/version-check.j2' %} +COPY entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] +{% include 'partials/jshell.j2' %} \ No newline at end of file diff --git a/docker_templates/partials/arch-variable.j2 b/docker_templates/partials/arch-variable.j2 index 0256e81e9..a2ea57886 100644 --- a/docker_templates/partials/arch-variable.j2 +++ b/docker_templates/partials/arch-variable.j2 @@ -1,4 +1,4 @@ -{%- if os == "ubuntu" %} +{%- if os == "ubuntu" or os == "debian" %} ARCH="$(dpkg --print-architecture)"; \ {%- elif os == "alpine-linux" %} ARCH="$(apk --print-arch)"; \ diff --git a/docker_templates/scripts/entrypoint.debian.sh b/docker_templates/scripts/entrypoint.debian.sh new file mode 120000 index 000000000..270d10241 --- /dev/null +++ b/docker_templates/scripts/entrypoint.debian.sh @@ -0,0 +1 @@ +entrypoint.ubuntu.sh \ No newline at end of file diff --git a/dockerhub_doc_config_update.sh b/dockerhub_doc_config_update.sh index 3da9764eb..c7d7a7a62 100755 --- a/dockerhub_doc_config_update.sh +++ b/dockerhub_doc_config_update.sh @@ -36,12 +36,10 @@ all_packages="jdk jre" # Fetch the latest manifest from the official repo wget -q -O official-eclipse-temurin https://raw.githubusercontent.com/docker-library/official-images/master/library/eclipse-temurin -oses="alpine ubuntu centos ubi windowsservercore-ltsc2022 nanoserver-ltsc2022 windowsservercore-1809 nanoserver-1809" +oses="alpine ubuntu centos debian ubi windowsservercore-ltsc2022 nanoserver-ltsc2022 windowsservercore-1809 nanoserver-1809" # The image which is used by default when pulling shared tags on linux e.g 8-jdk default_linux_image="jammy" -git_repo="https://github.com/adoptium/containers/blob/master" - # Get the latest git commit of the current repo. # This is assumed to have all the latest dockerfiles already. gitcommit=$(git log | head -1 | awk '{ print $2 }') @@ -70,6 +68,7 @@ function generate_official_image_tags() { case $os in "ubuntu") distro=$(echo $dfdir | awk -F '/' '{ print $4 }' ) ;; + "debian") distro="debian-$(echo $dfdir | awk -F '/' '{ print $4 }' )" ;; "ubi") distro=$(echo $dfdir | awk -F '/' '{ print $4 }' ) ;; "centos") distro="centos7" ;; "windows") distro=$(echo $dfdir | awk -F '/' '{ print $4 }' ) ;; @@ -134,6 +133,10 @@ function generate_official_image_arches() { # arm is arm32v7 and aarch64 is arm64v8 for docker builds # shellcheck disable=SC2046,SC2005,SC1003,SC2086,SC2063 arches=$(echo $(grep ') \\' ${file} | sed 's/\(powerpc:common64\)//;s/\(i386:x86-64\)//;s/\(x86_64\)//;s/\(arm64\)//;s/\(armhf\)//;s/\(s390:64-bit\)//;s/\(arm\)/arm32v7/;s/\(ppc64el\)/ppc64le/;s/\(aarch64\)/arm64v8/;' | grep -v "*" | sed 's/) \\//g; s/|//g' | sort) | sed 's/ /, /g') + # if distro contains debian only ship riscv64 + if [[ "${distro}" == debian* ]]; then + arches="riscv64" + fi fi } @@ -184,7 +187,7 @@ function print_official_image_file() { rm -f ${official_docker_image_file} print_official_header -official_os_ignore_array=(clefos debian debianslim leap tumbleweed) +official_os_ignore_array=(clefos leap tumbleweed) # Generate config and doc info only for "supported" official builds. function generate_official_image_info() { diff --git a/generate_dockerfiles.py b/generate_dockerfiles.py index e3c32cf9e..93e97806a 100644 --- a/generate_dockerfiles.py +++ b/generate_dockerfiles.py @@ -55,6 +55,7 @@ def archHelper(arch, os_family): os_name = configuration["os"] base_image = configuration["image"] deprecated = configuration.get("deprecated", None) + starts_from = configuration.get("starts_from", 0) versions = configuration.get( "versions", config["supported_distributions"]["Versions"] ) @@ -68,10 +69,12 @@ def archHelper(arch, os_family): # if deprecated is set and version is greater than or equal to deprecated, skip if deprecated and version >= deprecated: continue + # if starts_from is set and version is less than starts_from, skip + if version < starts_from: + continue print("Generating Dockerfiles for", base_image, "-", version) for image_type in ["jdk", "jre"]: output_directory = os.path.join(str(version), image_type, directory) - os.makedirs(output_directory, exist_ok=True) # Fetch latest release for version from Adoptium API url = f"https://api.adoptium.net/v3/assets/feature_releases/{version}/ga?page=0&image_type={image_type}&os={os_family}&page_size=1&vendor=eclipse" @@ -126,6 +129,9 @@ def archHelper(arch, os_family): # If arch_data is empty, skip updating the dockerfile if arch_data.__len__() == 0: continue + else: + # Create the directory if it doesn't exist + os.makedirs(output_directory, exist_ok=True) # Sort arch_data by key arch_data = dict(sorted(arch_data.items()))