From 336c64afee8e01a4fd50fcfa1d6f89a6aa5ec092 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Sat, 23 Sep 2023 17:51:45 +0200 Subject: [PATCH] fixup! Add Java 21 --- .github/workflows/ci.yml | 6 ++++- bin/build-old.sh | 45 ++++++++++++++++++++++++++++++++++++ bin/build.sh | 49 ++++++++-------------------------------- bin/test-base.sh | 6 +++-- settings.sh | 5 +++- 5 files changed, 68 insertions(+), 43 deletions(-) create mode 100755 bin/build-old.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89e85b6..c93addd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,11 @@ jobs: run: | set -xeuo pipefail . ./settings.sh - ./bin/build.sh + if [ "${JDK_VERSION}" = "java17" ] || [ "${JDK_VERSION}" = "java20" ]; then + ./bin/build-old.sh + else + ./bin/build.sh + fi docker image ls env: JDK_VERSION: ${{ matrix.jdk_version }} diff --git a/bin/build-old.sh b/bin/build-old.sh new file mode 100755 index 0000000..79daef6 --- /dev/null +++ b/bin/build-old.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -xeuo pipefail + +docker pull "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" || true +docker pull "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" || true +docker pull "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" || true + +docker build \ + --pull `#base is public, make sure to use the latest greatest` \ + --file Dockerfile \ + --build-arg "JDK_VERSION=${JDK_VERSION}" \ + --build-arg "GRAAL_JDK_VERSION=${GRAAL_JDK_VERSION}" \ + --cache-from "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" \ + --tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" \ + . + +docker build \ + --file Dockerfile.native \ + --build-arg "GRAAL_VERSION=${GRAAL_VERSION}" \ + --build-arg "JDK_VERSION=${JDK_VERSION}" \ + --cache-from "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" \ + --tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" \ + . + +docker build \ + --file Dockerfile.polyglot \ + --build-arg "GRAAL_VERSION=${GRAAL_VERSION}" \ + --build-arg "JDK_VERSION=${JDK_VERSION}" \ + --cache-from "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" \ + --tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" \ + . + +docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" "${IMAGE_NAME}:${JDK_VERSION}" +docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" "${IMAGE_NAME}:${JDK_VERSION}-native" +docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-all" +docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:${JDK_VERSION}-polyglot" +docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:${JDK_VERSION}-all" + +if [ "${DEFAULT_IMAGE}" = "true" ]; then + docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" "${IMAGE_NAME}:latest" + docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" "${IMAGE_NAME}:native" + docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:polyglot" + docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-all" "${IMAGE_NAME}:all" +fi diff --git a/bin/build.sh b/bin/build.sh index 232e8a6..72ab3d3 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -2,58 +2,29 @@ set -xeuo pipefail -docker pull "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" || true -docker pull "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" || true -docker pull "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" || true +docker pull "${IMAGE_NAME}:${JDK_VERSION}" || true +docker pull "${IMAGE_NAME}:${JDK_VERSION}-native" || true docker build \ --pull `#base is public, make sure to use the latest greatest` \ --file Dockerfile \ --build-arg "JDK_VERSION=${JDK_VERSION}" \ --build-arg "GRAAL_JDK_VERSION=${GRAAL_JDK_VERSION}" \ - --cache-from "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" \ - --tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" \ + --cache-from "${IMAGE_NAME}:${JDK_VERSION}" \ + --tag "${IMAGE_NAME}:${JDK_VERSION}" \ . docker build \ --file Dockerfile.native \ - --build-arg "GRAAL_VERSION=${GRAAL_VERSION}" \ --build-arg "JDK_VERSION=${JDK_VERSION}" \ - --cache-from "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" \ - --tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" \ + --cache-from "${IMAGE_NAME}:${JDK_VERSION}-native" \ + --tag "${IMAGE_NAME}:${JDK_VERSION}-native" \ . -# Polyglot image depends on `gu` which is removed from Java21. While it's possible -# to provide equivalent functionality (e.g. `pyenv install graalpy-community-23.1.0` -# for Python), it not necessarily makes sense (bigger image). For now, don't build -# polyglot. -if [ "${JDK_VERSION}" != "java21" ]; then - docker build \ - --file Dockerfile.polyglot \ - --build-arg "GRAAL_VERSION=${GRAAL_VERSION}" \ - --build-arg "JDK_VERSION=${JDK_VERSION}" \ - --cache-from "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" \ - --tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" \ - . -fi - -docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" "${IMAGE_NAME}:${JDK_VERSION}" -docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" "${IMAGE_NAME}:${JDK_VERSION}-native" - -if [ "${JDK_VERSION}" != "java21" ]; then - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-all" - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:${JDK_VERSION}-polyglot" - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:${JDK_VERSION}-all" -else - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-all" - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" "${IMAGE_NAME}:${JDK_VERSION}-all" -fi +docker tag "${IMAGE_NAME}:${JDK_VERSION}-native" "${IMAGE_NAME}:${JDK_VERSION}-all" if [ "${DEFAULT_IMAGE}" = "true" ]; then - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}" "${IMAGE_NAME}:latest" - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-native" "${IMAGE_NAME}:native" - if [ "${JDK_VERSION}" != "java21" ]; then - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-polyglot" "${IMAGE_NAME}:polyglot" - fi - docker tag "${IMAGE_NAME}:${GRAAL_VERSION}-${JDK_VERSION}-all" "${IMAGE_NAME}:all" + docker tag "${IMAGE_NAME}:${JDK_VERSION}" "${IMAGE_NAME}:latest" + docker tag "${IMAGE_NAME}:${JDK_VERSION}-native" "${IMAGE_NAME}:native" + docker tag "${IMAGE_NAME}:${JDK_VERSION}-all" "${IMAGE_NAME}:all" fi diff --git a/bin/test-base.sh b/bin/test-base.sh index c2db8ec..d0aee3c 100755 --- a/bin/test-base.sh +++ b/bin/test-base.sh @@ -8,5 +8,7 @@ docker run --rm "${image}" java -version 2>&1 | grep GraalVM docker run --rm "${image}" java -version 2>&1 | grep "openjdk version \"${JDK_VERSION#java}." docker run --rm "${image}" bash -c '$JAVA_HOME/bin/java -version' 2>&1 | tee /dev/stderr | grep GraalVM -# Verify GRAAL_VERSION matches what we built -docker run --rm -i "${image}" polyglot --version | tee /dev/stderr | grep -xF "GraalVM CE polyglot launcher ${GRAAL_VERSION}" +if test -v GRAAL_VERSION; then + # Verify GRAAL_VERSION matches what we built + docker run --rm -i "${image}" polyglot --version | tee /dev/stderr | grep -xF "GraalVM CE polyglot launcher ${GRAAL_VERSION}" +fi diff --git a/settings.sh b/settings.sh index 570160b..bdc525b 100644 --- a/settings.sh +++ b/settings.sh @@ -1,16 +1,19 @@ #!bash export IMAGE_NAME=findepi/graalvm # by necessity, this is also set in derived images' FROM directive -export GRAAL_VERSION="23.0.1" +GRAAL_VERSION="23.0.1" export JDK_VERSION="${JDK_VERSION-java17}" export DEFAULT_IMAGE="${DEFAULT_IMAGE-false}" if [ "${JDK_VERSION}" = "java17" ]; then GRAAL_JDK_VERSION="17.0.8" + export GRAAL_VERSION elif [ "${JDK_VERSION}" = "java20" ]; then GRAAL_JDK_VERSION="20.0.2" + export GRAAL_VERSION elif [ "${JDK_VERSION}" = "java21" ]; then GRAAL_JDK_VERSION="21.0.0" + unset GRAAL_VERSION # unverifiable else echo "Unknown JDK_VERSION ${JDK_VERSION}" >&2 exit 1