|
1 |
| -# Copyright (c) 2019, 2024 Oracle and/or its affiliates. |
| 1 | +# Copyright (c) 2019, 2025 Oracle and/or its affiliates. |
2 | 2 | #
|
3 | 3 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
4 | 4 | #
|
5 | 5 | # ORACLE DOCKERFILES PROJECT
|
6 | 6 | # --------------------------
|
7 | 7 | # This is the Dockerfile for Oracle JDK 11 on Oracle Linux 8
|
8 | 8 | #
|
| 9 | +# ARGS |
| 10 | +# ---- |
| 11 | +# This docker file requires two arguments: |
| 12 | +# 1) JDK11_TOKEN is a valid dowload token for JDK 11. It can be created in cloud.oracle.com/jms under Java Download |
| 13 | +# Token generation is documented on https://docs.cloud.oracle.com/en-us/iaas/jms/doc/java-download.html |
| 14 | +# 2) OCI_REGION is the Oracle Cloud Infrastucture (OCI) region where the token is generated. |
| 15 | +# |
9 | 16 | # REQUIRED FILES TO BUILD THIS IMAGE
|
10 | 17 | # ----------------------------------
|
| 18 | +# This dockerfile will download a copy of latest version of JDK 11 from |
| 19 | +# https://javamanagementservice-download.<OCI_REGION>.oci.oraclecloud.com/java/11/latest/ |
11 | 20 | #
|
12 |
| -# (1) jdk-11.XX_linux-x64_bin.tar.gz or jdk-11.XX_linux-aarch64_bin.tar.gz |
13 |
| -# Download from https://www.oracle.com/java/technologies/downloads/ |
| 21 | +# It will use either x64 or aarch64 depending on the target platform |
14 | 22 | #
|
15 | 23 | # HOW TO BUILD THIS IMAGE
|
16 | 24 | # -----------------------
|
17 |
| -# Put all downloaded files in the same directory as this Dockerfile |
18 | 25 | # Run:
|
19 |
| -# $ docker build -t oracle/jdk:11 . |
20 |
| -# |
21 |
| -# This command is already scripted in build.sh so you can alternatively run |
22 |
| -# $ bash build.sh 8 |
| 26 | +# $ docker build --file Dockerfile.ol8 --tag oracle/jdk:11 --build-arg JDK11_TOKEN=<token> --build-arg OCI_REGION=<region> . |
23 | 27 | #
|
24 | 28 | # The builder image will be used to uncompress the tar.gz file with the Java Runtime.
|
25 | 29 |
|
26 | 30 | FROM oraclelinux:8 as builder
|
| 31 | +ARG JDK11_TOKEN |
| 32 | +ARG OCI_REGION |
27 | 33 |
|
28 | 34 | LABEL maintainer="Aurelio Garcia-Ribeyro < [email protected]>"
|
29 | 35 |
|
| 36 | +# Since the files are compressed as tar.gz first dnf install tar. |
| 37 | +# gzip is already in oraclelinux:8 |
30 | 38 | RUN dnf install -y tar
|
31 | 39 |
|
32 | 40 | # Default to UTF-8 file.encoding
|
33 | 41 | ENV LANG en_US.UTF-8
|
34 | 42 |
|
35 |
| - |
36 | 43 | # Environment variables for the builder image.
|
37 | 44 | # Required to validate that you are using the correct file
|
38 | 45 |
|
39 |
| -ENV JAVA_HOME=/usr/java/jdk-11 |
| 46 | +ENV JAVA_URL=https://javamanagementservice-download."${OCI_REGION}".oci.oraclecloud.com/java/11/latest/ \ |
| 47 | + JAVA_HOME=/usr/java/jdk-11 |
40 | 48 |
|
41 |
| -## |
42 |
| -COPY *.tar.gz /tmp/ |
43 | 49 | SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
44 | 50 | RUN set -eux; \
|
45 | 51 | ARCH="$(uname -m)" && \
|
| 52 | + # Java uses just x64 in the name of the tarball |
46 | 53 | if [ "$ARCH" = "x86_64" ]; \
|
47 |
| - then \ |
48 |
| - mv "$(ls /tmp/jdk-11*_linux-x64_bin.tar.gz)" /tmp/jdk.tar.gz ; \ |
49 |
| - JAVA_SHA256=d22d0fcca761861a1eb2f5f6eb116c933354e8b1f76b3cda189c722cc0177c98 ; \ |
50 |
| - else \ |
51 |
| - mv "$(ls /tmp/jdk-11*_linux-aarch64_bin.tar.gz)" /tmp/jdk.tar.gz ; \ |
52 |
| - JAVA_SHA256=3fc0d93f6363d32723c293ba5a9016e8ab27410351ed804020cfe71e87d3bc0a ; \ |
| 54 | + then ARCH="x64"; \ |
53 | 55 | fi && \
|
54 |
| - echo "$JAVA_SHA256 */tmp/jdk.tar.gz" | sha256sum -c -; \ |
| 56 | + JAVA_PKG="$JAVA_URL"jdk-11_linux-"${ARCH}"_bin.tar.gz; \ |
| 57 | + JAVA_SHA256="$(curl -L "$JAVA_PKG".sha256)" ; \ |
| 58 | + curl -L --header token:${JDK11_TOKEN} --output /tmp/jdk.tgz "$JAVA_PKG" && \ |
| 59 | + echo "$JAVA_SHA256" */tmp/jdk.tgz | sha256sum -c; \ |
55 | 60 | mkdir -p "$JAVA_HOME"; \
|
56 |
| - tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1 |
| 61 | + tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1 |
57 | 62 |
|
58 | 63 | ## Get a fresh version of Oracle Linux 8 for the final image
|
59 | 64 | FROM oraclelinux:8
|
60 | 65 |
|
61 | 66 | # Default to UTF-8 file.encoding
|
62 | 67 | ENV LANG en_US.UTF-8
|
63 |
| - |
64 | 68 | ENV JAVA_HOME=/usr/java/jdk-11
|
65 |
| - |
66 | 69 | ENV PATH $JAVA_HOME/bin:$PATH
|
67 | 70 |
|
68 | 71 | # Copy the uncompressed Java Runtime from the builder image
|
69 | 72 | COPY --from=builder $JAVA_HOME $JAVA_HOME
|
70 | 73 |
|
71 | 74 | RUN set -eux; \
|
| 75 | + # Ensure we get the latest OL 8 updates available at build time |
72 | 76 | dnf -y update; \
|
73 | 77 | dnf install -y \
|
74 |
| -# JDK assumes freetype is available |
75 |
| - freetype fontconfig \ |
| 78 | + # JDK assumes freetype is available |
| 79 | + freetype fontconfig \ |
76 | 80 | ; \
|
77 | 81 | rm -rf /var/cache/dnf; \
|
78 | 82 | ln -sfT "$JAVA_HOME" /usr/java/default; \
|
79 | 83 | ln -sfT "$JAVA_HOME" /usr/java/latest; \
|
80 | 84 | for bin in "$JAVA_HOME/bin/"*; do \
|
81 |
| - base="$(basename "$bin")"; \ |
82 |
| - [ ! -e "/usr/bin/$base" ]; \ |
83 |
| - alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \ |
| 85 | + base="$(basename "$bin")"; \ |
| 86 | + [ ! -e "/usr/bin/$base" ]; \ |
| 87 | + alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \ |
84 | 88 | done; \
|
85 |
| -# -Xshare:dump will create a CDS archive to improve startup in subsequent runs |
| 89 | + # -Xshare:dump will create a CDS archive to improve startup in subsequent runs |
86 | 90 | java -Xshare:dump;
|
87 | 91 |
|
88 | 92 | CMD ["jshell"]
|
0 commit comments