From 5873c6ce633dd250f71eb1d9ad068342fa7a2937 Mon Sep 17 00:00:00 2001 From: tw29845 <187752787+tw29845@users.noreply.github.com> Date: Mon, 18 Aug 2025 12:29:57 +0000 Subject: [PATCH 1/4] Bump OpenJDK to version 21, bump Gradle to version 8.14.3, & bump Maven to version 3.9.11 (cherry picked from commit 906f85feab404c9b1ad0dba6b9353b755a90ec4e) --- images/java/ubuntu.Dockerfile | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/images/java/ubuntu.Dockerfile b/images/java/ubuntu.Dockerfile index baa7a3c..07630f8 100644 --- a/images/java/ubuntu.Dockerfile +++ b/images/java/ubuntu.Dockerfile @@ -3,43 +3,45 @@ FROM codercom/enterprise-base:ubuntu # Run everything as root USER root -# Install JDK (OpenJDK 8) -RUN DEBIAN_FRONTEND="noninteractive" apt-get update -y && \ - apt-get install -y openjdk-11-jdk -ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 +ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 ENV PATH=$PATH:$JAVA_HOME/bin +ENV DEBIAN_FRONTEND=noninteractive + +# Install JDK (OpenJDK 21) +RUN apt-get update -y \ + && apt-get install openjdk-21-jdk -y --no-install-recommends --no-install-suggests # Install Maven -ARG MAVEN_VERSION=3.9.10 -ARG MAVEN_SHA512=4ef617e421695192a3e9a53b3530d803baf31f4269b26f9ab6863452d833da5530a4d04ed08c36490ad0f141b55304bceed58dbf44821153d94ae9abf34d0e1b +ARG MAVEN_VERSION=3.9.11 +ARG MAVEN_SHA512=bcfe4fe305c962ace56ac7b5fc7a08b87d5abd8b7e89027ab251069faebee516b0ded8961445d6d91ec1985dfe30f8153268843c89aa392733d1a3ec956c9978 ENV MAVEN_HOME=/usr/share/maven ENV MAVEN_CONFIG="/home/coder/.m2" RUN mkdir -p $MAVEN_HOME $MAVEN_HOME/ref \ - && echo "Downloading maven" \ + && echo "Downloading Maven" \ && curl -fsSL -o /tmp/apache-maven.tar.gz https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ && echo "Checking downloaded file hash" \ - && echo "${MAVEN_SHA512} /tmp/apache-maven.tar.gz" | sha512sum -c - \ - && echo "Unzipping maven" \ + && echo "${MAVEN_SHA512} /tmp/apache-maven.tar.gz" | sha512sum -c - \ + && echo "Unzipping Maven" \ && tar -xzf /tmp/apache-maven.tar.gz -C $MAVEN_HOME --strip-components=1 \ && echo "Cleaning and setting links" \ && rm -f /tmp/apache-maven.tar.gz \ && ln -s $MAVEN_HOME/bin/mvn /usr/bin/mvn # Install Gradle -ENV GRADLE_VERSION=6.7 -ARG GRADLE_SHA512=d495bc65379d2a854d2cca843bd2eeb94f381e5a7dcae89e6ceb6ef4c5835524932313e7f30d7a875d5330add37a5fe23447dc3b55b4d95dffffa870c0b24493 +ENV GRADLE_VERSION=8.14.3 +ARG GRADLE_SHA512=517ed3a20fe9f14f8c7e34778f5d248c61473e2b67e48a6d3341682a4bdcab502723f1d985fbb9e7f360a74a4e15f113d08a515bcc7b56dd5eb426f8e2cf82bf ENV GRADLE_HOME=/usr/bin/gradle RUN mkdir -p /usr/share/gradle /usr/share/gradle/ref \ - && echo "Downloading gradle" \ + && echo "Downloading Gradle" \ && curl -fsSL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip \ && echo "Checking downloaded file hash" \ - && echo "${GRADLE_SHA512} /tmp/gradle.zip" | sha512sum -c - \ - && echo "Unziping gradle" \ - && unzip -d /usr/share/gradle /tmp/gradle.zip \ + && echo "${GRADLE_SHA512} /tmp/gradle.zip" | sha512sum -c - \ + && echo "Unzipping Gradle" \ + && unzip -q -d /usr/share/gradle /tmp/gradle.zip \ && echo "Cleaning and setting links" \ && rm -f /tmp/gradle.zip \ && ln -s /usr/share/gradle/gradle-${GRADLE_VERSION} /usr/bin/gradle From 158975bfcbaa1dcbacbc690a9e927b428f26e113 Mon Sep 17 00:00:00 2001 From: tw29845 <187752787+tw29845@users.noreply.github.com> Date: Mon, 18 Aug 2025 14:49:12 +0000 Subject: [PATCH 2/4] Refactored Dockerfile to use SDKMAN. Reconfigured Java, Gradle, & Maven versioning to be controlled by SDKMAN (cherry picked from commit e7ac363b757f22656972be35ddc27c258238a310) --- images/java/ubuntu.Dockerfile | 67 ++++++++++------------------------- 1 file changed, 19 insertions(+), 48 deletions(-) diff --git a/images/java/ubuntu.Dockerfile b/images/java/ubuntu.Dockerfile index 07630f8..062a8b4 100644 --- a/images/java/ubuntu.Dockerfile +++ b/images/java/ubuntu.Dockerfile @@ -1,52 +1,23 @@ FROM codercom/enterprise-base:ubuntu -# Run everything as root -USER root - -ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 -ENV PATH=$PATH:$JAVA_HOME/bin -ENV DEBIAN_FRONTEND=noninteractive - -# Install JDK (OpenJDK 21) -RUN apt-get update -y \ - && apt-get install openjdk-21-jdk -y --no-install-recommends --no-install-suggests - -# Install Maven -ARG MAVEN_VERSION=3.9.11 -ARG MAVEN_SHA512=bcfe4fe305c962ace56ac7b5fc7a08b87d5abd8b7e89027ab251069faebee516b0ded8961445d6d91ec1985dfe30f8153268843c89aa392733d1a3ec956c9978 - -ENV MAVEN_HOME=/usr/share/maven +ENV DEBIAN_FRONTEND="noninteractive" +ENV JAVA_VERSION="21.0.8-tem" +ENV GRADLE_VERSION="8.14.3" +ENV MAVEN_VERSION="3.9.11" ENV MAVEN_CONFIG="/home/coder/.m2" -RUN mkdir -p $MAVEN_HOME $MAVEN_HOME/ref \ - && echo "Downloading Maven" \ - && curl -fsSL -o /tmp/apache-maven.tar.gz https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ - && echo "Checking downloaded file hash" \ - && echo "${MAVEN_SHA512} /tmp/apache-maven.tar.gz" | sha512sum -c - \ - && echo "Unzipping Maven" \ - && tar -xzf /tmp/apache-maven.tar.gz -C $MAVEN_HOME --strip-components=1 \ - && echo "Cleaning and setting links" \ - && rm -f /tmp/apache-maven.tar.gz \ - && ln -s $MAVEN_HOME/bin/mvn /usr/bin/mvn - -# Install Gradle -ENV GRADLE_VERSION=8.14.3 -ARG GRADLE_SHA512=517ed3a20fe9f14f8c7e34778f5d248c61473e2b67e48a6d3341682a4bdcab502723f1d985fbb9e7f360a74a4e15f113d08a515bcc7b56dd5eb426f8e2cf82bf - -ENV GRADLE_HOME=/usr/bin/gradle - -RUN mkdir -p /usr/share/gradle /usr/share/gradle/ref \ - && echo "Downloading Gradle" \ - && curl -fsSL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip \ - && echo "Checking downloaded file hash" \ - && echo "${GRADLE_SHA512} /tmp/gradle.zip" | sha512sum -c - \ - && echo "Unzipping Gradle" \ - && unzip -q -d /usr/share/gradle /tmp/gradle.zip \ - && echo "Cleaning and setting links" \ - && rm -f /tmp/gradle.zip \ - && ln -s /usr/share/gradle/gradle-${GRADLE_VERSION} /usr/bin/gradle - -ENV PATH=$PATH:$GRADLE_HOME/bin - -# Set back to coder user -USER coder +RUN sudo apt-get update && \ + sudo apt-get install --yes --no-install-recommends --no-install-suggests zip && \ + curl -fsSL "https://get.sdkman.io" | bash && \ + source "/home/coder/.sdkman/bin/sdkman-init.sh" && \ + sdk version && \ + sdk install java $JAVA_VERSION && \ + sdk default java $JAVA_VERSION && \ + sdk install gradle $GRADLE_VERSION && \ + sdk default gradle $GRADLE_VERSION && \ + sdk install maven $MAVEN_VERSION && \ + sdk default maven $MAVEN_VERSION && \ + sdk flush && \ + sdk current java && \ + sdk current gradle && \ + sdk current maven From a2c211e319af114ba6bfbbd72689ebe5033691d2 Mon Sep 17 00:00:00 2001 From: tw29845 <187752787+tw29845@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:20:19 +0000 Subject: [PATCH 3/4] Verify SDKMAN install script. Flush APT and SDKMAN caches to shrinks image size. Formatting. (cherry picked from commit a555519675a1c49d62d65ab8a6bc856a105537ca) --- images/java/ubuntu.Dockerfile | 54 ++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/images/java/ubuntu.Dockerfile b/images/java/ubuntu.Dockerfile index 062a8b4..00ee73c 100644 --- a/images/java/ubuntu.Dockerfile +++ b/images/java/ubuntu.Dockerfile @@ -1,23 +1,37 @@ FROM codercom/enterprise-base:ubuntu -ENV DEBIAN_FRONTEND="noninteractive" -ENV JAVA_VERSION="21.0.8-tem" -ENV GRADLE_VERSION="8.14.3" -ENV MAVEN_VERSION="3.9.11" -ENV MAVEN_CONFIG="/home/coder/.m2" +ARG DEBIAN_FRONTEND="noninteractive" +ARG SDKMAN_SHA512="ade94c3b8454bac9411139a46adbd68a16f05766b9bc6fa7061535bbce353c93578393e46cc0d90c630691774d1057b234134fe7af105e1e649f4e8811794de4" -RUN sudo apt-get update && \ - sudo apt-get install --yes --no-install-recommends --no-install-suggests zip && \ - curl -fsSL "https://get.sdkman.io" | bash && \ - source "/home/coder/.sdkman/bin/sdkman-init.sh" && \ - sdk version && \ - sdk install java $JAVA_VERSION && \ - sdk default java $JAVA_VERSION && \ - sdk install gradle $GRADLE_VERSION && \ - sdk default gradle $GRADLE_VERSION && \ - sdk install maven $MAVEN_VERSION && \ - sdk default maven $MAVEN_VERSION && \ - sdk flush && \ - sdk current java && \ - sdk current gradle && \ - sdk current maven +ENV SDKMAN_DIR="/home/coder/.sdkman" \ + SDKMAN_CLI_AUTO_CONFIRM=true \ + JAVA_VERSION="21.0.8-tem" \ + GRADLE_VERSION="8.14.3" \ + MAVEN_VERSION="3.9.11" \ + MAVEN_CONFIG="/home/coder/.m2" + +USER root + +RUN apt-get update -qq && \ + apt-get install -qq -y \ + --no-install-recommends \ + --no-install-suggests \ + zip && \ + rm -rf /var/lib/apt/lists/* + +USER coder + +RUN curl -fsSL https://get.sdkman.io -o /tmp/install_sdkman.sh && \ + echo "${SDKMAN_SHA512} /tmp/install_sdkman.sh" | sha512sum -c - && \ + bash /tmp/install_sdkman.sh && \ + rm /tmp/install_sdkman.sh && \ + bash -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && \ + sdk install java ${JAVA_VERSION} && \ + sdk default java ${JAVA_VERSION} && \ + sdk install gradle ${GRADLE_VERSION} && \ + sdk default gradle ${GRADLE_VERSION} && \ + sdk install maven ${MAVEN_VERSION} && \ + sdk default maven ${MAVEN_VERSION} && \ + sdk flush archives && \ + sdk flush temp && \ + sdk current" From 06bab22e7899aeb4d8c8d09e4c952e47d8ca8636 Mon Sep 17 00:00:00 2001 From: tw29845 <187752787+tw29845@users.noreply.github.com> Date: Thu, 21 Aug 2025 09:47:59 +0000 Subject: [PATCH 4/4] Updated to use CI mode SDKMAN install script (cherry picked from commit da1d939e8ef5441bc23ffa1a8eb34a4523ce4e13) --- images/java/ubuntu.Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/images/java/ubuntu.Dockerfile b/images/java/ubuntu.Dockerfile index 00ee73c..6b05882 100644 --- a/images/java/ubuntu.Dockerfile +++ b/images/java/ubuntu.Dockerfile @@ -1,10 +1,9 @@ FROM codercom/enterprise-base:ubuntu ARG DEBIAN_FRONTEND="noninteractive" -ARG SDKMAN_SHA512="ade94c3b8454bac9411139a46adbd68a16f05766b9bc6fa7061535bbce353c93578393e46cc0d90c630691774d1057b234134fe7af105e1e649f4e8811794de4" +ARG SDKMAN_SHA512="a8fc6a336d31f2e4980cfe39ee9f11a0f2ee70bc721094b7ea63b953fd1675474765a4e273d6575ea207aa59c15f4fe867e963c0c47580f2131edc2ae8d4fd34" ENV SDKMAN_DIR="/home/coder/.sdkman" \ - SDKMAN_CLI_AUTO_CONFIRM=true \ JAVA_VERSION="21.0.8-tem" \ GRADLE_VERSION="8.14.3" \ MAVEN_VERSION="3.9.11" \ @@ -21,7 +20,7 @@ RUN apt-get update -qq && \ USER coder -RUN curl -fsSL https://get.sdkman.io -o /tmp/install_sdkman.sh && \ +RUN curl -fsSL "https://get.sdkman.io?ci=true" -o /tmp/install_sdkman.sh && \ echo "${SDKMAN_SHA512} /tmp/install_sdkman.sh" | sha512sum -c - && \ bash /tmp/install_sdkman.sh && \ rm /tmp/install_sdkman.sh && \