Skip to content

Add Temurin JDK 24 #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# syntax=docker/dockerfile:1.6

ARG LATEST_VERSION
FROM eclipse-temurin:${LATEST_VERSION}-jdk-noble AS temurin-latest

# Intermediate image used to prune cruft from JDKs and squash them all.
FROM cimg/base:current-22.04 AS all-jdk
ARG LATEST_VERSION

COPY --from=eclipse-temurin:8-jdk-jammy /opt/java/openjdk /usr/lib/jvm/8
COPY --from=eclipse-temurin:11-jdk-jammy /opt/java/openjdk /usr/lib/jvm/11
COPY --from=eclipse-temurin:17-jdk-jammy /opt/java/openjdk /usr/lib/jvm/17
COPY --from=eclipse-temurin:21-jdk-jammy /opt/java/openjdk /usr/lib/jvm/21
COPY --from=temurin-latest /opt/java/openjdk /usr/lib/jvm/${LATEST_VERSION}

COPY --from=azul/zulu-openjdk:7 /usr/lib/jvm/zulu7 /usr/lib/jvm/7
COPY --from=azul/zulu-openjdk:8 /usr/lib/jvm/zulu8 /usr/lib/jvm/zulu8
Expand Down Expand Up @@ -51,20 +56,24 @@ RUN <<-EOT
EOT

FROM scratch AS default-jdk
ARG LATEST_VERSION

COPY --from=all-jdk /usr/lib/jvm/8 /usr/lib/jvm/8
COPY --from=all-jdk /usr/lib/jvm/11 /usr/lib/jvm/11
COPY --from=all-jdk /usr/lib/jvm/17 /usr/lib/jvm/17
COPY --from=all-jdk /usr/lib/jvm/21 /usr/lib/jvm/21
COPY --from=all-jdk /usr/lib/jvm/${LATEST_VERSION} /usr/lib/jvm/${LATEST_VERSION}

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

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

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

#Set some odd looking variables, since their default values are wrong and it is unclear how they are used
# Set some odd looking variables, since their default values are wrong and it is unclear how they are used.
ENV JAVA_DEBIAN_VERSION=unused
ENV JAVA_VERSION=unused

# Setup environment variables to point to all jvms we have
# Set up environment variables to point to all jvms we have.
ENV JAVA_8_HOME=/usr/lib/jvm/8
ENV JAVA_11_HOME=/usr/lib/jvm/11
ENV JAVA_17_HOME=/usr/lib/jvm/17
ENV JAVA_21_HOME=/usr/lib/jvm/21
ENV JAVA_${LATEST_VERSION}_HOME=/usr/lib/jvm/${LATEST_VERSION}

ENV JAVA_HOME=${JAVA_8_HOME}
ENV PATH=${JAVA_HOME}/bin:${PATH}
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# dd-trace-java-docker-build

Docker images for continuous integration jobs at [dd-trace-java](https://github.com/datadog/dd-trace-java).
Expand All @@ -8,8 +7,8 @@ Docker images for continuous integration jobs at [dd-trace-java](https://github.
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).

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

## Development
Expand Down
35 changes: 32 additions & 3 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eu

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

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

readonly VARIANTS=(
7
Expand Down Expand Up @@ -45,6 +45,23 @@ function compute_metadata() {
GIT_HEAD_REF="$(git show-ref --head --hash ^HEAD)"
}

function compute_latest_version() {
# Java versions are typically released towards the end of the month in March and September,
# so we use the version from the previous release cycle until the month after the release.
local base_year=2025
local base_version=23

version="$((base_version + ($(date +%Y) - base_year) * 2))"
if [ "$(date +%m)" -ge 4 ]; then
version="$((version + 1))"
fi
if [ "$(date +%m)" -ge 10 ]; then
version="$((version + 1))"
fi

export LATEST_VERSION="$version"
}

# docker build wrapper with common arguments
# See https://github.com/opencontainers/image-spec/blob/main/annotations.md for common labels
# See https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
Expand All @@ -54,6 +71,7 @@ function docker_build() {
shift
shift
docker build \
--build-arg LATEST_VERSION=$LATEST_VERSION \
--platform linux/amd64 \
--label org.opencontainers.image.created="$BUILD_DATE" \
--label org.opencontainers.image.source=https://github.com/DataDog/dd-trace-java-docker-build \
Expand All @@ -71,6 +89,7 @@ function image_name() {

function do_build() {
compute_metadata
compute_latest_version
docker_build base "$(image_name base)"
docker_build full "$(image_name latest)"
if [ -n "${GITHUB_OUTPUT+unset}" ]; then
Expand Down Expand Up @@ -133,13 +152,19 @@ function do_inner_test() {
local variant="${1}"
variant_lower="${variant,,}"
variant_upper="${variant^^}"
java_latest_home="JAVA_${LATEST_VERSION}_HOME"
set -x
"$JAVA_HOME/bin/java" -version
"$JAVA_8_HOME/bin/java" -version
"$JAVA_11_HOME/bin/java" -version
"$JAVA_17_HOME/bin/java" -version
"$JAVA_21_HOME/bin/java" -version
"${!java_latest_home}/bin/java" -version
if [[ $variant != base && $variant != latest ]]; then
if [[ $variant == "stable" ]]; then
variant_lower="${LATEST_VERSION}"
variant_upper="${LATEST_VERSION}"
fi
env_lower="JAVA_${variant_lower}_HOME"
env_upper="JAVA_${variant_upper}_HOME"
"${!env_lower}/bin/java" -version
Expand All @@ -148,8 +173,8 @@ function do_inner_test() {
}

function do_describe() {
local image
compute_metadata
local image
image="$(image_name latest)"
docker run \
--user "$(id -u):$(id -g)" \
Expand Down Expand Up @@ -179,7 +204,11 @@ function do_inner_describe() {
echo "## JDKs"
echo
for variant in "${BASE_VARIANTS[@]}" "${VARIANTS[@]}"; do
variant_upper="${variant^^}"
if [[ $variant == "stable" ]]; then
variant_upper="${LATEST_VERSION}"
else
variant_upper="${variant^^}"
fi
env_upper="JAVA_${variant_upper}_HOME"
echo "* $env_upper"
echo '```'
Expand Down
Loading