Skip to content

Commit

Permalink
Changed the JDK 17 and earlier dockerfiles to download the binaries f…
Browse files Browse the repository at this point in the history
…rom cloud.oracle.com, using download tokens, instead of having to be manually updated for all CPUs. Dropped the Oracle Linux 7 dockerfiles. Some dockerfiles had an extension with the Oracle Linux name but the "default" ones did not. Normalized it so that all Dockerfiles now indicate which version of Oracle Linux they use."

Signed-off-by: Aurelio Garcia-Ribeyro <[email protected]>
  • Loading branch information
aureliogrb authored and Djelibeybi committed Jan 14, 2025
1 parent 872b40a commit 0f1830b
Show file tree
Hide file tree
Showing 21 changed files with 210 additions and 503 deletions.
90 changes: 0 additions & 90 deletions OracleJava/11/Dockerfile

This file was deleted.

60 changes: 32 additions & 28 deletions OracleJava/11/Dockerfile.ol8
Original file line number Diff line number Diff line change
@@ -1,88 +1,92 @@
# Copyright (c) 2019, 2024 Oracle and/or its affiliates.
# Copyright (c) 2019, 2025 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 11 on Oracle Linux 8
#
# ARGS
# ----
# This docker file requires two arguments:
# 1) JDK11_TOKEN is a valid dowload token for JDK 11. It can be created in cloud.oracle.com/jms under Java Download
# Token generation is documented on https://docs.cloud.oracle.com/en-us/iaas/jms/doc/java-download.html
# 2) OCI_REGION is the Oracle Cloud Infrastucture (OCI) region where the token is generated.
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# This dockerfile will download a copy of latest version of JDK 11 from
# https://javamanagementservice-download.<OCI_REGION>.oci.oraclecloud.com/java/11/latest/
#
# (1) jdk-11.XX_linux-x64_bin.tar.gz or jdk-11.XX_linux-aarch64_bin.tar.gz
# Download from https://www.oracle.com/java/technologies/downloads/
# It will use either x64 or aarch64 depending on the target platform
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/jdk:11 .
#
# This command is already scripted in build.sh so you can alternatively run
# $ bash build.sh 8
# $ docker build --file Dockerfile.ol8 --tag oracle/jdk:11 --build-arg JDK11_TOKEN=<token> --build-arg OCI_REGION=<region> .
#
# The builder image will be used to uncompress the tar.gz file with the Java Runtime.

FROM oraclelinux:8 as builder
ARG JDK11_TOKEN
ARG OCI_REGION

LABEL maintainer="Aurelio Garcia-Ribeyro <[email protected]>"

# Since the files are compressed as tar.gz first dnf install tar.
# gzip is already in oraclelinux:8
RUN 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_HOME=/usr/java/jdk-11
ENV JAVA_URL=https://javamanagementservice-download."${OCI_REGION}".oci.oraclecloud.com/java/11/latest/ \
JAVA_HOME=/usr/java/jdk-11

##
COPY *.tar.gz /tmp/
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 \
mv "$(ls /tmp/jdk-11*_linux-x64_bin.tar.gz)" /tmp/jdk.tar.gz ; \
JAVA_SHA256=d22d0fcca761861a1eb2f5f6eb116c933354e8b1f76b3cda189c722cc0177c98 ; \
else \
mv "$(ls /tmp/jdk-11*_linux-aarch64_bin.tar.gz)" /tmp/jdk.tar.gz ; \
JAVA_SHA256=3fc0d93f6363d32723c293ba5a9016e8ab27410351ed804020cfe71e87d3bc0a ; \
then ARCH="x64"; \
fi && \
echo "$JAVA_SHA256 */tmp/jdk.tar.gz" | sha256sum -c -; \
JAVA_PKG="$JAVA_URL"jdk-11_linux-"${ARCH}"_bin.tar.gz; \
JAVA_SHA256="$(curl -L "$JAVA_PKG".sha256)" ; \
curl -L --header token:${JDK11_TOKEN} --output /tmp/jdk.tgz "$JAVA_PKG" && \
echo "$JAVA_SHA256" */tmp/jdk.tgz | sha256sum -c; \
mkdir -p "$JAVA_HOME"; \
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1
tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1

## Get a fresh version of Oracle Linux 8 for the final image
FROM oraclelinux:8

# Default to UTF-8 file.encoding
ENV LANG en_US.UTF-8

ENV JAVA_HOME=/usr/java/jdk-11

ENV PATH $JAVA_HOME/bin:$PATH

# 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 8 updates available at build time
dnf -y update; \
dnf install -y \
# JDK assumes freetype is available
freetype fontconfig \
# JDK assumes freetype is available
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; \
base="$(basename "$bin")"; \
[ ! -e "/usr/bin/$base" ]; \
alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \
done; \
# -Xshare:dump will create a CDS archive to improve startup in subsequent runs
# -Xshare:dump will create a CDS archive to improve startup in subsequent runs
java -Xshare:dump;

CMD ["jshell"]
14 changes: 0 additions & 14 deletions OracleJava/11/build.sh

This file was deleted.

87 changes: 0 additions & 87 deletions OracleJava/17/Dockerfile

This file was deleted.

Loading

0 comments on commit 0f1830b

Please sign in to comment.