From fa24c6d56a6df05a54dd5c75e6f17ce025f2bde6 Mon Sep 17 00:00:00 2001 From: Aurelio Garcia-Ribeyro Date: Fri, 19 Jul 2024 08:53:33 -0700 Subject: [PATCH] created a docker file to offer JDK 21 on OL9 as well as the existing one on OL 8. Renamed some of the old dockerfiles from Dockerfile.8 to Dockerfile.ol8 to make their purpose more clear; updated build.sh accordingly Signed-off-by: Aurelio Garcia-Ribeyro --- .../11/{Dockerfile.8 => Dockerfile.ol8} | 2 +- OracleJava/11/build.sh | 2 +- OracleJava/21/Dockerfile.ol9 | 88 +++++++++++++++++++ OracleJava/21/build.sh | 11 ++- .../8/jdk/{Dockerfile.8 => Dockerfile.ol8} | 0 OracleJava/8/jdk/build.sh | 2 +- .../{Dockerfile.8 => Dockerfile.ol8} | 2 +- OracleJava/8/serverjre/build.sh | 2 +- 8 files changed, 102 insertions(+), 7 deletions(-) rename OracleJava/11/{Dockerfile.8 => Dockerfile.ol8} (99%) create mode 100644 OracleJava/21/Dockerfile.ol9 rename OracleJava/8/jdk/{Dockerfile.8 => Dockerfile.ol8} (100%) rename OracleJava/8/serverjre/{Dockerfile.8 => Dockerfile.ol8} (97%) diff --git a/OracleJava/11/Dockerfile.8 b/OracleJava/11/Dockerfile.ol8 similarity index 99% rename from OracleJava/11/Dockerfile.8 rename to OracleJava/11/Dockerfile.ol8 index 736c0aa2e8..bf5f91775d 100644 --- a/OracleJava/11/Dockerfile.8 +++ b/OracleJava/11/Dockerfile.ol8 @@ -19,7 +19,7 @@ # $ docker build -t oracle/jdk:11 . # # This command is already scripted in build.sh so you can alternatively run -# $ bash build.sh +# $ bash build.sh 8 # # The builder image will be used to uncompress the tar.gz file with the Java Runtime. diff --git a/OracleJava/11/build.sh b/OracleJava/11/build.sh index 03b7e10b40..62d1bac11d 100755 --- a/OracleJava/11/build.sh +++ b/OracleJava/11/build.sh @@ -7,7 +7,7 @@ if test "$1" = "8" then echo "Building Oracle JDK 11 on Oracle Linux 8" - docker build --file Dockerfile.8 --tag oracle/jdk:11-ol8 . + docker build --file Dockerfile.ol8 --tag oracle/jdk:11-ol8 . else echo "Building Oracle JDK 11 on Oracle Linux 7 slim" docker build --tag oracle/jdk:11-ol7 . diff --git a/OracleJava/21/Dockerfile.ol9 b/OracleJava/21/Dockerfile.ol9 new file mode 100644 index 0000000000..331d978365 --- /dev/null +++ b/OracleJava/21/Dockerfile.ol9 @@ -0,0 +1,88 @@ +# Copyright (c) 2022, 2024 Oracle and/or its affiliates. +# +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# ORACLE DOCKERFILES PROJECT +# -------------------------- +# This is the Dockerfile for Oracle JDK 21 on Oracle Linux 9 +# +# REQUIRED FILES TO BUILD THIS IMAGE +# ---------------------------------- +# This dockerfile will download a copy of JDK 21 from +# https://download.oracle.com/java/21/latest/jdk-21_linux-_bin.tar.gz +# +# It will use either x64 or aarch64 depending on the target platform +# +# HOW TO BUILD THIS IMAGE +# ----------------------- +# Run: +# $ docker build -t oracle/jdk:21 . +# +# This command is already scripted in build.sh so you can alternatively run +# $ bash build.sh 9 +# +# The builder image will be used to uncompress the tar.gz file with the Java Runtime. + +FROM oraclelinux:9 as builder + +LABEL maintainer="Aurelio Garcia-Ribeyro " + +# Since the files are compressed as tar.gz first dnf install tar. gzip is already in oraclelinux:9 +RUN set -eux; \ + dnf install -y tar; + +# Default to UTF-8 file.encoding +ENV LANG en_US.UTF-8 + +# Environment variables for the builder image. +# Required to validate that you are using the correct file + +ENV JAVA_URL=https://download.oracle.com/java/21/latest \ + JAVA_HOME=/usr/java/jdk-21 + +## +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN set -eux; \ + ARCH="$(uname -m)" && \ + # Java uses just x64 in the name of the tarball + if [ "$ARCH" = "x86_64" ]; \ + then ARCH="x64"; \ + fi && \ + JAVA_PKG="$JAVA_URL"/jdk-21_linux-"${ARCH}"_bin.tar.gz ; \ + JAVA_SHA256=$(curl "$JAVA_PKG".sha256) ; \ + curl --output /tmp/jdk.tgz "$JAVA_PKG" && \ + echo "$JAVA_SHA256" */tmp/jdk.tgz | sha256sum -c; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1 + +## Get a fresh version of OL9 for the final image +FROM oraclelinux:9 + +# Default to UTF-8 file.encoding +ENV LANG en_US.UTF-8 +ENV JAVA_HOME=/usr/java/jdk-21 +ENV PATH $JAVA_HOME/bin:$PATH + +# If you need the Java Version you can read it from the release file with +# JAVA_VERSION=$(sed -n '/^JAVA_VERSION="/{s///;s/"//;p;}' "$JAVA_HOME"/release); + +# Copy the uncompressed Java Runtime from the builder image +COPY --from=builder $JAVA_HOME $JAVA_HOME + +RUN set -eux; \ +# Ensure we get the latest OL 9 updates available at build time + dnf -y update; \ +# JDK assumes freetype is available + dnf install -y \ + freetype fontconfig \ + ; \ + rm -rf /var/cache/dnf; \ + ln -sfT "$JAVA_HOME" /usr/java/default; \ + ln -sfT "$JAVA_HOME" /usr/java/latest; \ + for bin in "$JAVA_HOME/bin/"*; do \ + base="$(basename "$bin")"; \ + [ ! -e "/usr/bin/$base" ]; \ + alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \ + done; + +CMD ["jshell"] \ No newline at end of file diff --git a/OracleJava/21/build.sh b/OracleJava/21/build.sh index a7a4466eee..0890bd661b 100755 --- a/OracleJava/21/build.sh +++ b/OracleJava/21/build.sh @@ -4,5 +4,12 @@ # # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. -echo "Building Oracle JDK 21 on Oracle Linux 8" -docker build --file Dockerfile --tag oracle/jdk:21-ol8 . \ No newline at end of file + +if test "$1" = "9" +then + echo "Building Oracle JDK 21 on Oracle Linux 9" + docker build --file Dockerfile.ol9 --tag oracle/jdk:21-ol9 . +else + echo "Building Oracle JDK 21 on Oracle Linux 8" + docker build --file Dockerfile --tag oracle/jdk:21-ol8 . +fi \ No newline at end of file diff --git a/OracleJava/8/jdk/Dockerfile.8 b/OracleJava/8/jdk/Dockerfile.ol8 similarity index 100% rename from OracleJava/8/jdk/Dockerfile.8 rename to OracleJava/8/jdk/Dockerfile.ol8 diff --git a/OracleJava/8/jdk/build.sh b/OracleJava/8/jdk/build.sh index d53d91b184..419004e5b5 100755 --- a/OracleJava/8/jdk/build.sh +++ b/OracleJava/8/jdk/build.sh @@ -7,7 +7,7 @@ if test "$1" = "8" then echo "Building Oracle JDK 8 on Oracle Linux 8" - docker build --file Dockerfile.8 --tag oracle/jdk:8-ol8 . + docker build --file Dockerfile.ol8 --tag oracle/jdk:8-ol8 . else echo "Building Oracle JDK 8 on Oracle Linux 7 slim" docker build --tag oracle/jdk:8-ol7 . diff --git a/OracleJava/8/serverjre/Dockerfile.8 b/OracleJava/8/serverjre/Dockerfile.ol8 similarity index 97% rename from OracleJava/8/serverjre/Dockerfile.8 rename to OracleJava/8/serverjre/Dockerfile.ol8 index f9a14393e3..b198171c0a 100644 --- a/OracleJava/8/serverjre/Dockerfile.8 +++ b/OracleJava/8/serverjre/Dockerfile.ol8 @@ -46,7 +46,7 @@ RUN set -eux; \ mkdir -p "$JAVA_HOME"; \ tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1; -## Get a fresh version of SLIM for the final image +## Get a fresh version of OL 8 for the final image FROM oraclelinux:8 diff --git a/OracleJava/8/serverjre/build.sh b/OracleJava/8/serverjre/build.sh index 04988e3eab..0d316a7bed 100755 --- a/OracleJava/8/serverjre/build.sh +++ b/OracleJava/8/serverjre/build.sh @@ -7,7 +7,7 @@ if test "$1" = "8" then echo "Building Oracle Server JRE 8 on Oracle Linux 8" - docker build --file Dockerfile.8 --tag oracle/serverjre:8-ol8 . + docker build --file Dockerfile.ol8 --tag oracle/serverjre:8-ol8 . else echo "Building Oracle Server JRE 8 on Oracle Linux 7 slim" docker build --tag oracle/serverjre:8-ol7 .