-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathDockerfile.ol9
More file actions
88 lines (75 loc) · 2.85 KB
/
Copy pathDockerfile.ol9
File metadata and controls
88 lines (75 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright (c) 2022, 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 25 on Oracle Linux 9
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# This dockerfile will download a copy of JDK 25 from
# https://download.oracle.com/java/25/latest/jdk-25_linux-<ARCH>_bin.tar.gz
#
# It will use either x64 or aarch64 depending on the target platform
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Run:
# $ docker build --file Dockerfile.ol9 --tag oracle/jdk:25 .
#
# This command is already scripted in build.sh so you can alternatively run
# $ bash build.sh
#
# 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 <aurelio.garciaribeyro@oracle.com>"
# 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/25/latest \
JAVA_HOME=/usr/java/jdk-25
##
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-25_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 Oracle Linux 9 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-25
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 Oracle Linux 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"]