Skip to content

Commit

Permalink
Updates to latest LTS Java 21 and recent maven (#76)
Browse files Browse the repository at this point in the history
This updates to the latest LTS version of Java 21.

This also updates maven as it has drifted a while, and removes a jlink
workaround that seems no longer necessary.

Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Dec 2, 2023
1 parent e420e5f commit 4ae30ff
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: deploy
# See https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
on:
push:
tags: '[0-9]+.[0-9]+.[0-9]+**' # Ex. 8.272.10 or 17.0.8_p7
tags: '[0-9]+.[0-9]+.[0-9]+**' # Ex. 8.272.10 or 21.0.1_p12

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
# We can't cache Docker without using buildx because GH actions restricts /var/lib/docker
# That's ok because DOCKER_PARENT_IMAGE is always ghcr.io and local anyway.
- name: Test LTS JDK
run: build-bin/configure_test && build-bin/test 17.0.8_p7
run: build-bin/configure_test && build-bin/test 21.0.1_p12
- name: Test latest JDK
run: build-bin/configure_test && build-bin/test
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
arch: # only test archs not already tested with GH actions
- arm64
- s390x
os: linux # required for arch different than amd64
os: linux # required for arch different from amd64
dist: focal # newest available distribution
language: bash
services: docker
Expand All @@ -19,7 +19,7 @@ before_install: | # Prevent test build of a documentation-only change.
install: ./build-bin/configure_test
script:
# Test LTS JDK
- ./build-bin/test 17.0.8_p7
- ./build-bin/test 21.0.1_p12
# Test latest JDK
- ./build-bin/test

Expand Down
19 changes: 8 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# docker_parent_image is the base layer of full and jre image
#
# Use latest version here: https://github.com/orgs/openzipkin/packages/container/package/alpine
ARG docker_parent_image=ghcr.io/openzipkin/alpine:3.18.2
ARG docker_parent_image=ghcr.io/openzipkin/alpine:3.18.5

# java_version is hard-coded here to allow the following to work:
# * `docker build https://github.com/openzipkin/docker-java.git`
#
# When updating, also update the README
# * Use current version from https://pkgs.alpinelinux.org/packages?name=openjdk17, stripping
# * Use current version from https://pkgs.alpinelinux.org/packages?name=openjdk21, stripping
# the `-rX` at the end.
ARG java_version=17.0.8_p7
ARG java_version=21.0.1_p12

# We copy files from the context into a scratch container first to avoid a problem where docker and
# docker-compose don't share layer hashes https://github.com/docker/compose/issues/883 normally.
Expand All @@ -29,11 +29,11 @@ FROM $docker_parent_image as base
# * `docker build https://github.com/openzipkin/docker-java.git`
#
# When updating, also update the README
# * Use current version from https://pkgs.alpinelinux.org/packages?name=openjdk15
# * Use current version from https://pkgs.alpinelinux.org/packages?name=openjdk21
# This is defined in many places because Docker has no "env" script functionality unless you use
# docker-compose: When updating, update everywhere.
ARG java_version
ARG java_home=/usr/lib/jvm/java-17-openjdk
ARG java_home=/usr/lib/jvm/java-21-openjdk
LABEL java-version=$java_version
LABEL java-home=$java_home

Expand All @@ -50,7 +50,7 @@ ENTRYPOINT ["java", "-jar"]
FROM base as jdk
LABEL org.opencontainers.image.description="OpenJDK on Alpine Linux"
ARG java_version
ARG maven_version=3.8.8
ARG maven_version=3.9.6
LABEL maven-version=$maven_version

COPY --from=code /code/install.sh .
Expand All @@ -61,11 +61,8 @@ FROM jdk as install

WORKDIR /install

# Opt out of --strip-debug when openjdk15+arm64 per https://github.com/openzipkin/docker-java/issues/34
# This is because we cannot set the following in jlink -Djdk.lang.Process.launchMechanism=vfork
RUN if [ -d "/usr/lib/jvm/java-17-openjdk" ] && uname -m | grep -E 'aarch64|s390x'; then strip=""; else strip="--strip-debug"; fi && \
# Included modules cherry-picked from https://docs.oracle.com/en/java/javase/15/docs/api/
jlink --vm=server --no-header-files --no-man-pages --compress=0 ${strip} --add-modules \
# Included modules cherry-picked from https://docs.oracle.com/en/java/javase/21/docs/api/
RUN jlink --vm=server --no-header-files --no-man-pages --compress=0 --strip-debug --add-modules \
java.base,java.logging,\
# java.desktop includes java.beans which is used by Spring
java.desktop,\
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

GitHub Container Registry: [ghcr.io/openzipkin/java](https://github.com/orgs/openzipkin/packages/container/package/java) includes:
* `master` tag: latest commit
* `MAJOR.MINOR.PATCH` tag: release corresponding to a [Current OpenJDK Version](https://pkgs.alpinelinux.org/packages?name=openjdk15)
* `MAJOR.MINOR.PATCH` tag: release corresponding to a [Current OpenJDK Version](https://pkgs.alpinelinux.org/packages?name=openjdk21)

Tags ending in `-jre` include only a JRE where unqualified tags include the full JDK, Maven, and a
few build utilities.
Expand All @@ -15,27 +15,27 @@ This is an internal base layer primarily used in [zipkin](https://github.com/ope

To try the image, run the `java -version` command:
```bash
docker run --rm ghcr.io/openzipkin/java:17.0.8_p7 -version
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment (build 17.0.5+8-alpine-r2)
OpenJDK 64-Bit Server VM (build 17.0.5+8-alpine-r2, mixed mode, sharing)
docker run --rm ghcr.io/openzipkin/java:21.0.1_p12 -version
openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment (build 21.0.1+12-alpine-r0)
OpenJDK 64-Bit Server VM (build 21.0.1+12-alpine-r0, mixed mode, sharing)
```

## Release process
Build the `Dockerfile` using the current version without the revision classifier from here:
* https://pkgs.alpinelinux.org/packages?name=openjdk15
* https://pkgs.alpinelinux.org/packages?name=openjdk21
```bash
# Note 17.0.8_p7 not 17.0.8_p7-r0!
./build-bin/build 17.0.8_p7
# Note 21.0.1_p12 not 21.0.1_p12-r0!
./build-bin/build 21.0.1_p12
```

Next, verify the built image matches that version:
```bash
docker run --rm openzipkin/java:test -version
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment (build 17.0.5+8-alpine-r2)
OpenJDK 64-Bit Server VM (build 17.0.5+8-alpine-r2, mixed mode, sharing)
openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment (build 21.0.1+12-alpine-r0)
OpenJDK 64-Bit Server VM (build 21.0.1+12-alpine-r0, mixed mode, sharing)
```

To release the image, push a tag matching the arg to `build-bin/build` (ex `17.0.8_p7`).
To release the image, push a tag matching the arg to `build-bin/build` (ex `21.0.1_p12`).
This triggers a [GitHub Actions](https://github.com/openzipkin/docker-java/actions) job to push the image.
4 changes: 2 additions & 2 deletions build-bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ explicitly defined and `on.tags` is a [glob pattern](https://docs.github.com/en/
```yaml
on:
push:
tags: '[0-9]+.[0-9]+.[0-9]+**' # Ex. 8.272.10 or 17.0.8_p7
tags: '[0-9]+.[0-9]+.[0-9]+**' # Ex. 8.272.10 or 21.0.1_p12
branches: master
jobs:
Expand Down Expand Up @@ -203,7 +203,7 @@ jobs:
- if [ "${SHOULD_DEPLOY}" != "true" ]; then travis_terminate 0; fi
- travis_wait ./build-bin/deploy master
- stage: deploy
# Ex. 8.272.10 or 17.0.8_p7
# Ex. 8.272.10 or 21.0.1_p12
if: tag =~ /^[0-9]+\.[0-9]+\.[0-9]+/ AND type = push AND env(GH_TOKEN) IS present
install: ./build-bin/configure_deploy
script: ./build-bin/deploy ${TRAVIS_TAG}
Expand Down
6 changes: 3 additions & 3 deletions build-bin/docker/docker_args
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2019-2020 The OpenZipkin Authors
# Copyright 2019-2023 The OpenZipkin Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -46,7 +46,7 @@ if [ -n "${DOCKER_TARGET}" ]; then
fi

# When non-empty, becomes the base layer including tag appropriate for the image being built.
# Ex. ghcr.io/openzipkin/java:17.0.8_p7-jre
# Ex. ghcr.io/openzipkin/java:21.0.1_p12-jre
#
# This is not required to be a base (FROM scratch) image like ghcr.io/openzipkin/alpine:3.12.3
# See https://docs.docker.com/glossary/#parent-image
Expand All @@ -60,7 +60,7 @@ if [ -n "${ALPINE_VERSION}" ]; then
docker_args="${docker_args} --build-arg alpine_version=${ALPINE_VERSION}"
fi

# When non-empty, becomes the build-arg java_version. Ex. "17.0.8_p7"
# When non-empty, becomes the build-arg java_version. Ex. "21.0.1_p12"
# Used to align base layers from https://github.com/orgs/openzipkin/packages/container/package/java
if [ -n "${JAVA_VERSION}" ]; then
docker_args="${docker_args} --build-arg java_version=${JAVA_VERSION}"
Expand Down
14 changes: 7 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2019-2020 The OpenZipkin Authors
# Copyright 2019-2023 The OpenZipkin Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand All @@ -13,8 +13,8 @@
# the License.

# Install OS packages that support most software we build
# * openjdk15-jdk: smaller than openjdk15, which includes docs and demos
# * openjdk15-jmods: needed for module support
# * openjdk21-jdk: smaller than openjdk21, which includes docs and demos
# * openjdk21-jmods: needed for module support
# * binutils: needed for some node modules and jlink --strip-debug
# * tar: BusyBox built-in tar doesn't support --strip=1
# * wget: BusyBox built-in wget doesn't support --tries=3
Expand All @@ -27,8 +27,8 @@ function maybe_log_crash() {
(cat $(ls hs_err_pid*.log) 2>&- || true) && exit 1;
}

java_version=${1?java_version is required. ex 17.0.8_p7}
maven_version=${2?maven_version is required. ex 3.6.3}
java_version=${1?java_version is required. ex --strip-debug}
maven_version=${2?maven_version is required. ex 3.9.6}
java_major_version=$(echo ${java_version}| cut -f1 -d .)
package=openjdk${java_major_version}

Expand All @@ -53,5 +53,5 @@ apache_backup_mirror=https://downloads.apache.org/
(wget ${apache_mirror}${maven_dist_path} || wget ${apache_backup_mirror}${maven_dist_path}) | tar xz --strip=1 -C maven
ln -s ${PWD}/maven/bin/mvn /usr/bin/mvn

mvn -q --batch-mode org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=maven.version -q -DforceStdout || maybe_log_crash
mvn -q --batch-mode org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get -Dmdep.skip
mvn -q --batch-mode org.apache.maven.plugins:maven-help-plugin:3.4.0:evaluate -Dexpression=maven.version -q -DforceStdout || maybe_log_crash
mvn -q --batch-mode org.apache.maven.plugins:maven-dependency-plugin:3.6.1:get -Dmdep.skip

0 comments on commit 4ae30ff

Please sign in to comment.