From f0a1dfce8edb06a1b71758b49886580e6ee271ff Mon Sep 17 00:00:00 2001 From: Rico Hermans Date: Fri, 12 May 2023 21:04:44 +0200 Subject: [PATCH] feat(superchain): switch to JDK 20 (#4082) Switch to a more recent version of the JDK. `jsii-pacmak` will keep on targeting Java 1.8, so this doesn't affect compatibility of the generated class files. What this will gain us is access to a more recent, optimized `javadoc` tool, which completes a lot faster than the one from JDK 8. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --- superchain/Dockerfile | 19 +++++++++++-------- superchain/README.md | 19 +++++++++++++++++-- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/superchain/Dockerfile b/superchain/Dockerfile index 0c3427e3d4..72f40ae514 100644 --- a/superchain/Dockerfile +++ b/superchain/Dockerfile @@ -157,13 +157,13 @@ RUN apt-get update && rm -rf $(pip cache dir) \ && rm -rf /var/lib/apt/lists/* -# Install JDK8 (Amazon Corretto 8) +# Install JDK20 (Amazon Corretto 20) COPY superchain/gpg/corretto.asc /tmp/corretto.asc RUN apt-key add /tmp/corretto.asc && rm /tmp/corretto.asc \ && echo "deb https://apt.corretto.aws stable main" > /etc/apt/sources.list.d/amazon-corretto.list \ && apt-get update \ && mkdir -p /usr/share/man/man1 \ - && apt-get -y install java-1.8.0-amazon-corretto-jdk \ + && apt-get -y install java-20-amazon-corretto-jdk \ && rm -rf /usr/share/man/man1 \ && rm -rf /var/lib/apt/lists/* @@ -244,9 +244,6 @@ COPY --chown=superchain:superchain superchain/m2-settings.xml /home/superchain/. COPY --chown=superchain:superchain superchain/ssh_config /home/superchain/.ssh/config RUN chmod 600 /home/superchain/.ssh/config -# Add the source used to build this Docker image (to facilitate re-builds, forensics) -COPY superchain /docker-source - # Create the attributions document RUN RUST_DOCS="${RUSTUP_HOME}/toolchains/$(rustup show active-toolchain | cut -d' ' -f 1)/share/doc" \ && RUSTUP_VERSION=$(rustup --version 2>/dev/null | cut -d' ' -f2) \ @@ -289,13 +286,13 @@ RUN RUST_DOCS="${RUSTUP_HOME}/toolchains/$(rustup show active-toolchain | cut -d && echo "------------------------------------ PATENTS ------------------------------------" >> /NOTICE \ && cat ${GOROOT}/PATENTS >> /NOTICE \ && echo "################################################################################" >> /NOTICE \ - && echo "java-1.8.0-amazon-corretto-jdk:" >> /NOTICE \ + && echo "java-20-amazon-corretto-jdk:" >> /NOTICE \ && echo "" >> /NOTICE \ && echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \ - && cat /usr/lib/jvm/java-1.8.0-amazon-corretto/LICENSE >> /NOTICE \ + && cat /usr/lib/jvm/java-20-amazon-corretto/LICENSE >> /NOTICE \ && echo "" >> /NOTICE \ && echo "------------------------------------ THIRD-PARTY NOTICES ------------------------------------" >> /NOTICE \ - && cat /usr/lib/jvm/java-1.8.0-amazon-corretto/THIRD_PARTY_README >> /NOTICE \ + && cat /usr/lib/jvm/java-20-amazon-corretto/ADDITIONAL_LICENSE_INFO >> /NOTICE \ && echo "################################################################################" >> /NOTICE \ && echo "maven:" >> /NOTICE \ && echo "" >> /NOTICE \ @@ -346,6 +343,10 @@ RUN RUST_DOCS="${RUSTUP_HOME}/toolchains/$(rustup show active-toolchain | cut -d ;fi \ ;done +# Add the source used to build this Docker image (to facilitate re-builds, forensics) +# Keep this at the end for max caching. +COPY superchain /docker-source + CMD ["/bin/bash"] ######################################################################################################################## @@ -357,6 +358,8 @@ ENV LANG="C.UTF-8" LC_ALL="C.UTF-8" \ CHARSET="UTF-8" \ \ + JAVA_HOME="/usr/lib/jvm/java-20-amazon-corretto" \ + \ DOTNET_CLI_TELEMETRY_OPTOUT="true" \ DOTNET_RUNNING_IN_CONTAINER="true" \ DOTNET_NOLOGO="true" \ diff --git a/superchain/README.md b/superchain/README.md index a53ccb97e8..1d29aaf33b 100644 --- a/superchain/README.md +++ b/superchain/README.md @@ -10,7 +10,7 @@ required in order to package [jsii] projects in all supported languages. SDK | Version ----------------|------------------------------------------- -`OpenJDK 8` | Amazon Corretto `>= 8.242.08.1` +`OpenJDK 20` | Amazon Corretto `>= 20.0.0` `.NET SDK` | `>= 6.0.14` `mono` | `>= 6.8.0.105` `Javascript` | see [NodeJS and NPM](#nodejs-and-npm) @@ -48,6 +48,21 @@ The previous image tags have been discontinued: - `:node14` (users shoudl migrate to `:1-buster-slim-node14`) - `:node14-nightly` (users shoudl migrate to `:1-buster-slim-node14-nightly`) +## Building + +This docker image must be built from the package root with the Dockerfile set to +`superchain/Dockerfile`: + +``` +jsii$ docker build . -f superchain/Dockerfile -t jsii/superchain:local +``` + +In case the tests fail, skip the tests and inspect the image manually: + +``` +jsii$ docker build . -f superchain/Dockerfile -t jsii/superchain:local --target=superchain +``` + ## NodeJS and NPM We build multiple versions of this image, for different versions of Node. They are available as: @@ -60,7 +75,7 @@ If you are building this image from source, you can control the Node version wit `NODE_MAJOR_VERSION` build argument: ``` -docker build [...] --build-arg NODE_MAJOR_VERSION=14 . +jsii$ docker build [...] --build-arg NODE_MAJOR_VERSION=16 ``` ## Included Tools & Utilities