Skip to content

Commit 408ee63

Browse files
committed
Add LATEST_VERSION parameter
1 parent cfa6a76 commit 408ee63

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +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
10-
COPY --from=openjdk:24-jdk /usr/java/openjdk-24 /usr/lib/jvm/24
14+
COPY --from=temurin-latest /opt/java/openjdk /usr/lib/jvm/${LATEST_VERSION}
1115

1216
COPY --from=azul/zulu-openjdk:7 /usr/lib/jvm/zulu7 /usr/lib/jvm/7
1317
COPY --from=azul/zulu-openjdk:8 /usr/lib/jvm/zulu8 /usr/lib/jvm/zulu8
@@ -52,16 +56,18 @@ RUN <<-EOT
5256
EOT
5357

5458
FROM scratch AS default-jdk
59+
ARG LATEST_VERSION=24
5560

5661
COPY --from=all-jdk /usr/lib/jvm/8 /usr/lib/jvm/8
5762
COPY --from=all-jdk /usr/lib/jvm/11 /usr/lib/jvm/11
5863
COPY --from=all-jdk /usr/lib/jvm/17 /usr/lib/jvm/17
5964
COPY --from=all-jdk /usr/lib/jvm/21 /usr/lib/jvm/21
60-
COPY --from=all-jdk /usr/lib/jvm/24 /usr/lib/jvm/24
65+
COPY --from=all-jdk /usr/lib/jvm/${LATEST_VERSION} /usr/lib/jvm/${LATEST_VERSION}
6166

6267
# Base image with minimum requirements to build the project.
6368
# Based on CircleCI Base Image with Ubuntu 22.04.3 LTS, present in most runners.
6469
FROM cimg/base:current-22.04 AS base
70+
ARG LATEST_VERSION=24
6571

6672
# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
6773
LABEL org.opencontainers.image.source=https://github.com/DataDog/dd-trace-java-docker-build
@@ -118,7 +124,7 @@ ENV JAVA_8_HOME=/usr/lib/jvm/8
118124
ENV JAVA_11_HOME=/usr/lib/jvm/11
119125
ENV JAVA_17_HOME=/usr/lib/jvm/17
120126
ENV JAVA_21_HOME=/usr/lib/jvm/21
121-
ENV JAVA_24_HOME=/usr/lib/jvm/24
127+
ENV JAVA_${LATEST_VERSION}_HOME=/usr/lib/jvm/${LATEST_VERSION}
122128

123129
ENV JAVA_HOME=${JAVA_8_HOME}
124130
ENV PATH=${JAVA_HOME}/bin:${PATH}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Docker images for continuous integration jobs at [dd-trace-java](https://github.
77
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).
88

99
Image variants are available on a per JDK basis:
10-
- The `base` variant, and its aliases `8`, `11`, `17`, and `21`, contains the base Eclipse Temurin JDK 8, 11, 17, and 21 versions,
10+
- The `base` variant, and its aliases `8`, `11`, `17`, `21`, and `latest`, contains the base Eclipse Temurin JDK 8, 11, 17, 21, and latest JDK versions,
1111
- 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,
12-
- The `latest` variant contains the base JDKs and all the above specific JDKs, including OpenJDK 24.
12+
- The `latest` variant contains the base JDKs and all the above specific JDKs.
1313

1414
## Development
1515

build

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
@@ -130,16 +149,19 @@ function do_test() {
130149
}
131150

132151
function do_inner_test() {
152+
compute_latest_version
133153
local variant="${1}"
134154
variant_lower="${variant,,}"
135155
variant_upper="${variant^^}"
156+
java_latest_home="JAVA_${LATEST_VERSION}_HOME"
136157
set -x
137158
"$JAVA_HOME/bin/java" -version
138159
"$JAVA_8_HOME/bin/java" -version
139160
"$JAVA_11_HOME/bin/java" -version
140161
"$JAVA_17_HOME/bin/java" -version
141162
"$JAVA_21_HOME/bin/java" -version
142-
"$JAVA_24_HOME/bin/java" -version
163+
"${!java_latest_home}/bin/java" -version
164+
143165
if [[ $variant != base && $variant != latest ]]; then
144166
env_lower="JAVA_${variant_lower}_HOME"
145167
env_upper="JAVA_${variant_upper}_HOME"

0 commit comments

Comments
 (0)