Skip to content

Commit fa24c6d

Browse files
aureliogrbDjelibeybi
authored andcommitted
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 <[email protected]>
1 parent 62b04da commit fa24c6d

File tree

8 files changed

+102
-7
lines changed

8 files changed

+102
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# $ docker build -t oracle/jdk:11 .
2020
#
2121
# This command is already scripted in build.sh so you can alternatively run
22-
# $ bash build.sh
22+
# $ bash build.sh 8
2323
#
2424
# The builder image will be used to uncompress the tar.gz file with the Java Runtime.
2525

OracleJava/11/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
if test "$1" = "8"
88
then
99
echo "Building Oracle JDK 11 on Oracle Linux 8"
10-
docker build --file Dockerfile.8 --tag oracle/jdk:11-ol8 .
10+
docker build --file Dockerfile.ol8 --tag oracle/jdk:11-ol8 .
1111
else
1212
echo "Building Oracle JDK 11 on Oracle Linux 7 slim"
1313
docker build --tag oracle/jdk:11-ol7 .

OracleJava/21/Dockerfile.ol9

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright (c) 2022, 2024 Oracle and/or its affiliates.
2+
#
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
#
5+
# ORACLE DOCKERFILES PROJECT
6+
# --------------------------
7+
# This is the Dockerfile for Oracle JDK 21 on Oracle Linux 9
8+
#
9+
# REQUIRED FILES TO BUILD THIS IMAGE
10+
# ----------------------------------
11+
# This dockerfile will download a copy of JDK 21 from
12+
# https://download.oracle.com/java/21/latest/jdk-21_linux-<ARCH>_bin.tar.gz
13+
#
14+
# It will use either x64 or aarch64 depending on the target platform
15+
#
16+
# HOW TO BUILD THIS IMAGE
17+
# -----------------------
18+
# Run:
19+
# $ docker build -t oracle/jdk:21 .
20+
#
21+
# This command is already scripted in build.sh so you can alternatively run
22+
# $ bash build.sh 9
23+
#
24+
# The builder image will be used to uncompress the tar.gz file with the Java Runtime.
25+
26+
FROM oraclelinux:9 as builder
27+
28+
LABEL maintainer="Aurelio Garcia-Ribeyro <[email protected]>"
29+
30+
# Since the files are compressed as tar.gz first dnf install tar. gzip is already in oraclelinux:9
31+
RUN set -eux; \
32+
dnf install -y tar;
33+
34+
# Default to UTF-8 file.encoding
35+
ENV LANG en_US.UTF-8
36+
37+
# Environment variables for the builder image.
38+
# Required to validate that you are using the correct file
39+
40+
ENV JAVA_URL=https://download.oracle.com/java/21/latest \
41+
JAVA_HOME=/usr/java/jdk-21
42+
43+
##
44+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
45+
RUN set -eux; \
46+
ARCH="$(uname -m)" && \
47+
# Java uses just x64 in the name of the tarball
48+
if [ "$ARCH" = "x86_64" ]; \
49+
then ARCH="x64"; \
50+
fi && \
51+
JAVA_PKG="$JAVA_URL"/jdk-21_linux-"${ARCH}"_bin.tar.gz ; \
52+
JAVA_SHA256=$(curl "$JAVA_PKG".sha256) ; \
53+
curl --output /tmp/jdk.tgz "$JAVA_PKG" && \
54+
echo "$JAVA_SHA256" */tmp/jdk.tgz | sha256sum -c; \
55+
mkdir -p "$JAVA_HOME"; \
56+
tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1
57+
58+
## Get a fresh version of OL9 for the final image
59+
FROM oraclelinux:9
60+
61+
# Default to UTF-8 file.encoding
62+
ENV LANG en_US.UTF-8
63+
ENV JAVA_HOME=/usr/java/jdk-21
64+
ENV PATH $JAVA_HOME/bin:$PATH
65+
66+
# If you need the Java Version you can read it from the release file with
67+
# JAVA_VERSION=$(sed -n '/^JAVA_VERSION="/{s///;s/"//;p;}' "$JAVA_HOME"/release);
68+
69+
# Copy the uncompressed Java Runtime from the builder image
70+
COPY --from=builder $JAVA_HOME $JAVA_HOME
71+
72+
RUN set -eux; \
73+
# Ensure we get the latest OL 9 updates available at build time
74+
dnf -y update; \
75+
# JDK assumes freetype is available
76+
dnf install -y \
77+
freetype fontconfig \
78+
; \
79+
rm -rf /var/cache/dnf; \
80+
ln -sfT "$JAVA_HOME" /usr/java/default; \
81+
ln -sfT "$JAVA_HOME" /usr/java/latest; \
82+
for bin in "$JAVA_HOME/bin/"*; do \
83+
base="$(basename "$bin")"; \
84+
[ ! -e "/usr/bin/$base" ]; \
85+
alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \
86+
done;
87+
88+
CMD ["jshell"]

OracleJava/21/build.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@
44
#
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
66

7-
echo "Building Oracle JDK 21 on Oracle Linux 8"
8-
docker build --file Dockerfile --tag oracle/jdk:21-ol8 .
7+
8+
if test "$1" = "9"
9+
then
10+
echo "Building Oracle JDK 21 on Oracle Linux 9"
11+
docker build --file Dockerfile.ol9 --tag oracle/jdk:21-ol9 .
12+
else
13+
echo "Building Oracle JDK 21 on Oracle Linux 8"
14+
docker build --file Dockerfile --tag oracle/jdk:21-ol8 .
15+
fi

OracleJava/8/jdk/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
if test "$1" = "8"
88
then
99
echo "Building Oracle JDK 8 on Oracle Linux 8"
10-
docker build --file Dockerfile.8 --tag oracle/jdk:8-ol8 .
10+
docker build --file Dockerfile.ol8 --tag oracle/jdk:8-ol8 .
1111
else
1212
echo "Building Oracle JDK 8 on Oracle Linux 7 slim"
1313
docker build --tag oracle/jdk:8-ol7 .
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ RUN set -eux; \
4646
mkdir -p "$JAVA_HOME"; \
4747
tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1;
4848

49-
## Get a fresh version of SLIM for the final image
49+
## Get a fresh version of OL 8 for the final image
5050

5151
FROM oraclelinux:8
5252

OracleJava/8/serverjre/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
if test "$1" = "8"
88
then
99
echo "Building Oracle Server JRE 8 on Oracle Linux 8"
10-
docker build --file Dockerfile.8 --tag oracle/serverjre:8-ol8 .
10+
docker build --file Dockerfile.ol8 --tag oracle/serverjre:8-ol8 .
1111
else
1212
echo "Building Oracle Server JRE 8 on Oracle Linux 7 slim"
1313
docker build --tag oracle/serverjre:8-ol7 .

0 commit comments

Comments
 (0)