Skip to content

Commit dc4d8e1

Browse files
authored
Merge pull request #93 from DataDog/sarahchen6/add-jdk-24
Add Temurin JDK 24
2 parents 709509c + 6078764 commit dc4d8e1

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# syntax=docker/dockerfile:1.6
22

3+
ARG LATEST_VERSION
4+
FROM eclipse-temurin:${LATEST_VERSION}-jdk-noble AS temurin-latest
5+
36
# Intermediate image used to prune cruft from JDKs and squash them all.
47
FROM cimg/base:current-22.04 AS all-jdk
8+
ARG LATEST_VERSION
59

610
COPY --from=eclipse-temurin:8-jdk-jammy /opt/java/openjdk /usr/lib/jvm/8
711
COPY --from=eclipse-temurin:11-jdk-jammy /opt/java/openjdk /usr/lib/jvm/11
812
COPY --from=eclipse-temurin:17-jdk-jammy /opt/java/openjdk /usr/lib/jvm/17
913
COPY --from=eclipse-temurin:21-jdk-jammy /opt/java/openjdk /usr/lib/jvm/21
14+
COPY --from=temurin-latest /opt/java/openjdk /usr/lib/jvm/${LATEST_VERSION}
1015

1116
COPY --from=azul/zulu-openjdk:7 /usr/lib/jvm/zulu7 /usr/lib/jvm/7
1217
COPY --from=azul/zulu-openjdk:8 /usr/lib/jvm/zulu8 /usr/lib/jvm/zulu8
@@ -51,20 +56,24 @@ RUN <<-EOT
5156
EOT
5257

5358
FROM scratch AS default-jdk
59+
ARG LATEST_VERSION
5460

5561
COPY --from=all-jdk /usr/lib/jvm/8 /usr/lib/jvm/8
5662
COPY --from=all-jdk /usr/lib/jvm/11 /usr/lib/jvm/11
5763
COPY --from=all-jdk /usr/lib/jvm/17 /usr/lib/jvm/17
5864
COPY --from=all-jdk /usr/lib/jvm/21 /usr/lib/jvm/21
65+
COPY --from=all-jdk /usr/lib/jvm/${LATEST_VERSION} /usr/lib/jvm/${LATEST_VERSION}
5966

60-
# Base image with minimunm requirenents to build the project.
67+
# Base image with minimum requirements to build the project.
6168
# Based on CircleCI Base Image with Ubuntu 22.04.3 LTS, present in most runners.
6269
FROM cimg/base:current-22.04 AS base
70+
ARG LATEST_VERSION
71+
ENV LATEST_VERSION=${LATEST_VERSION}
6372

6473
# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
6574
LABEL org.opencontainers.image.source=https://github.com/DataDog/dd-trace-java-docker-build
6675

67-
# Replace Docker Compose and yq versions by latest and remove docker-switch from CircleCI Base Image for security purposes
76+
# Replace Docker Compose and yq versions by latest and remove docker-switch from CircleCI Base Image for security purposes.
6877
RUN <<-EOT
6978
set -eu
7079
dockerPluginDir=/usr/local/lib/docker/cli-plugins
@@ -107,15 +116,16 @@ EOT
107116
# IBM specific env variables
108117
ENV IBM_JAVA_OPTIONS="-XX:+UseContainerSupport"
109118

110-
#Set some odd looking variables, since their default values are wrong and it is unclear how they are used
119+
# Set some odd looking variables, since their default values are wrong and it is unclear how they are used.
111120
ENV JAVA_DEBIAN_VERSION=unused
112121
ENV JAVA_VERSION=unused
113122

114-
# Setup environment variables to point to all jvms we have
123+
# Set up environment variables to point to all jvms we have.
115124
ENV JAVA_8_HOME=/usr/lib/jvm/8
116125
ENV JAVA_11_HOME=/usr/lib/jvm/11
117126
ENV JAVA_17_HOME=/usr/lib/jvm/17
118127
ENV JAVA_21_HOME=/usr/lib/jvm/21
128+
ENV JAVA_${LATEST_VERSION}_HOME=/usr/lib/jvm/${LATEST_VERSION}
119129

120130
ENV JAVA_HOME=${JAVA_8_HOME}
121131
ENV PATH=${JAVA_HOME}/bin:${PATH}

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# dd-trace-java-docker-build
32

43
Docker images for continuous integration jobs at [dd-trace-java](https://github.com/datadog/dd-trace-java).
@@ -8,8 +7,8 @@ Docker images for continuous integration jobs at [dd-trace-java](https://github.
87
Pre-built images are available in [GitHub Container Registry](https://github.com/DataDog/dd-trace-java-docker-build/pkgs/container/dd-trace-java-docker-build).
98

109
Image variants are available on a per JDK basis:
11-
- The `base` variant, and its aliases `8`, `11`, `17` and `21`, contains the base Eclipse Temurin JDK 8, 11, 17 and 21 versions,
12-
- The `zulu8`, `zulu11`, `oracle8`, `ibm8`, `semeru8`, `semeru11`, `semeru17`, `graalvm17` and `graalvm21` variants all contain the base JDKs in addition to their specific JDK from their name,
10+
- The `base` variant, and its aliases `8`, `11`, `17`, `21`, and `stable`, contains the base Eclipse Temurin JDK 8, 11, 17, 21, and latest stable JDK versions,
11+
- The `zulu8`, `zulu11`, `oracle8`, `ibm8`, `semeru8`, `semeru11`, `semeru17`, `graalvm17` and `graalvm21` variants all contain the base JDKs in addition to the specific JDK from their name,
1312
- The `latest` variant contains the base JDKs and all the above specific JDKs.
1413

1514
## Development

build

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -eu
33

44
readonly IMAGE_NAME="ghcr.io/datadog/dd-trace-java-docker-build"
55

6-
readonly BASE_VARIANTS=(8 11 17 21)
6+
readonly BASE_VARIANTS=(8 11 17 21 stable) # add an ea variant once the early access build is available
77

88
readonly VARIANTS=(
99
7
@@ -45,6 +45,23 @@ function compute_metadata() {
4545
GIT_HEAD_REF="$(git show-ref --head --hash ^HEAD)"
4646
}
4747

48+
function compute_latest_version() {
49+
# Java versions are typically released towards the end of the month in March and September,
50+
# so we use the version from the previous release cycle until the month after the release.
51+
local base_year=2025
52+
local base_version=23
53+
54+
version="$((base_version + ($(date +%Y) - base_year) * 2))"
55+
if [ "$(date +%m)" -ge 4 ]; then
56+
version="$((version + 1))"
57+
fi
58+
if [ "$(date +%m)" -ge 10 ]; then
59+
version="$((version + 1))"
60+
fi
61+
62+
export LATEST_VERSION="$version"
63+
}
64+
4865
# docker build wrapper with common arguments
4966
# See https://github.com/opencontainers/image-spec/blob/main/annotations.md for common labels
5067
# See https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
@@ -54,6 +71,7 @@ function docker_build() {
5471
shift
5572
shift
5673
docker build \
74+
--build-arg LATEST_VERSION=$LATEST_VERSION \
5775
--platform linux/amd64 \
5876
--label org.opencontainers.image.created="$BUILD_DATE" \
5977
--label org.opencontainers.image.source=https://github.com/DataDog/dd-trace-java-docker-build \
@@ -71,6 +89,7 @@ function image_name() {
7189

7290
function do_build() {
7391
compute_metadata
92+
compute_latest_version
7493
docker_build base "$(image_name base)"
7594
docker_build full "$(image_name latest)"
7695
if [ -n "${GITHUB_OUTPUT+unset}" ]; then
@@ -133,13 +152,19 @@ function do_inner_test() {
133152
local variant="${1}"
134153
variant_lower="${variant,,}"
135154
variant_upper="${variant^^}"
155+
java_latest_home="JAVA_${LATEST_VERSION}_HOME"
136156
set -x
137157
"$JAVA_HOME/bin/java" -version
138158
"$JAVA_8_HOME/bin/java" -version
139159
"$JAVA_11_HOME/bin/java" -version
140160
"$JAVA_17_HOME/bin/java" -version
141161
"$JAVA_21_HOME/bin/java" -version
162+
"${!java_latest_home}/bin/java" -version
142163
if [[ $variant != base && $variant != latest ]]; then
164+
if [[ $variant == "stable" ]]; then
165+
variant_lower="${LATEST_VERSION}"
166+
variant_upper="${LATEST_VERSION}"
167+
fi
143168
env_lower="JAVA_${variant_lower}_HOME"
144169
env_upper="JAVA_${variant_upper}_HOME"
145170
"${!env_lower}/bin/java" -version
@@ -148,8 +173,8 @@ function do_inner_test() {
148173
}
149174

150175
function do_describe() {
151-
local image
152176
compute_metadata
177+
local image
153178
image="$(image_name latest)"
154179
docker run \
155180
--user "$(id -u):$(id -g)" \
@@ -179,7 +204,11 @@ function do_inner_describe() {
179204
echo "## JDKs"
180205
echo
181206
for variant in "${BASE_VARIANTS[@]}" "${VARIANTS[@]}"; do
182-
variant_upper="${variant^^}"
207+
if [[ $variant == "stable" ]]; then
208+
variant_upper="${LATEST_VERSION}"
209+
else
210+
variant_upper="${variant^^}"
211+
fi
183212
env_upper="JAVA_${variant_upper}_HOME"
184213
echo "* $env_upper"
185214
echo '```'

0 commit comments

Comments
 (0)