Skip to content

Commit

Permalink
Merge pull request #98 from groovy/add-java-21
Browse files Browse the repository at this point in the history
Add Java 21
  • Loading branch information
keeganwitt authored Oct 11, 2023
2 parents ce5e447 + ddbcc55 commit 0ea910f
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [8-jdk-jammy, 11-jdk-jammy, 11-jdk-alpine, 17-jdk-jammy, 17-jdk-alpine]
version: [8-jdk-jammy, 11-jdk-jammy, 11-jdk-alpine, 17-jdk-jammy, 17-jdk-alpine, 21-jdk-jammy, 21-jdk-alpine]
steps:
- name: checkout
uses: actions/checkout@v2
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

* [jdk8](https://github.com/groovy/docker-groovy/blob/master/jdk8/Dockerfile)
* [jdk11](https://github.com/groovy/docker-groovy/blob/master/jdk11/Dockerfile)
* [jdk17, latest](https://github.com/groovy/docker-groovy/blob/master/jdk17/Dockerfile)
* [jdk11-alpine](https://github.com/groovy/docker-groovy/blob/master/jdk11-alpine/Dockerfile)
* [jdk17](https://github.com/groovy/docker-groovy/blob/master/jdk17/Dockerfile)
* [jdk17-alpine](https://github.com/groovy/docker-groovy/blob/master/jdk17-alpine/Dockerfile)
* [jdk21, latest](https://github.com/groovy/docker-groovy/blob/master/jdk21/Dockerfile)
* [jdk21-alpine](https://github.com/groovy/docker-groovy/blob/master/jdk21-alpine/Dockerfile)

## What is Groovy?

Expand Down
68 changes: 68 additions & 0 deletions jdk21-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM eclipse-temurin:21-jdk-alpine

CMD ["groovysh"]

ENV GROOVY_HOME /opt/groovy

RUN set -o errexit -o nounset \
&& echo "Adding groovy user and group" \
&& addgroup --system --gid 1000 groovy \
&& adduser --system --ingroup groovy --uid 1000 --shell /bin/ash groovy \
&& mkdir --parents /home/groovy/.groovy/grapes \
&& chown -R groovy:groovy /home/groovy \
&& chmod -R 1777 /home/groovy \
\
&& echo "Symlinking root .groovy to groovy .groovy" \
&& ln -s /home/groovy/.groovy /root/.groovy

VOLUME /home/groovy/.groovy/grapes

WORKDIR /home/groovy

ENV GROOVY_VERSION 4.0.15
RUN set -o errexit -o nounset \
&& echo "Installing build dependencies" \
&& apk add --no-cache --virtual .build-deps \
gnupg \
\
&& echo "Downloading Groovy" \
&& wget --no-verbose --output-document=groovy.zip "https://archive.apache.org/dist/groovy/${GROOVY_VERSION}/distribution/apache-groovy-binary-${GROOVY_VERSION}.zip" \
\
&& echo "Importing keys listed in http://www.apache.org/dist/groovy/KEYS from key server" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --no-tty --keyserver keyserver.ubuntu.com --recv-keys \
7FAA0F2206DE228F0DB01AD741321490758AAD6F \
331224E1D7BE883D16E8A685825C06C827AF6B66 \
34441E504A937F43EB0DAEF96A65176A0FB1CD0B \
9A810E3B766E089FFB27C70F11B595CEDC4AEBB5 \
81CABC23EECA0790E8989B361FF96E10F0E13706 \
\
&& echo "Checking download signature" \
&& wget --no-verbose --output-document=groovy.zip.asc "https://archive.apache.org/dist/groovy/${GROOVY_VERSION}/distribution/apache-groovy-binary-${GROOVY_VERSION}.zip.asc" \
&& gpg --batch --no-tty --verify groovy.zip.asc groovy.zip \
&& rm -rf "${GNUPGHOME}" \
&& rm groovy.zip.asc \
\
&& echo "Cleaning up build dependencies" \
&& apk del .build-deps \
\
&& echo "Installing Groovy" \
&& unzip groovy.zip \
&& rm groovy.zip \
&& mv "groovy-${GROOVY_VERSION}" "${GROOVY_HOME}/" \
&& ln -s "${GROOVY_HOME}/bin/grape" /usr/bin/grape \
&& ln -s "${GROOVY_HOME}/bin/groovy" /usr/bin/groovy \
&& ln -s "${GROOVY_HOME}/bin/groovyc" /usr/bin/groovyc \
&& ln -s "${GROOVY_HOME}/bin/groovyConsole" /usr/bin/groovyConsole \
&& ln -s "${GROOVY_HOME}/bin/groovydoc" /usr/bin/groovydoc \
&& ln -s "${GROOVY_HOME}/bin/groovysh" /usr/bin/groovysh \
&& ln -s "${GROOVY_HOME}/bin/java2groovy" /usr/bin/java2groovy \
\
&& echo "Editing startGroovy to include java.xml.bind module" \
&& sed --in-place 's|startGroovy ( ) {|startGroovy ( ) {\n JAVA_OPTS="$JAVA_OPTS --add-modules=ALL-SYSTEM"|' "${GROOVY_HOME}/bin/startGroovy"

USER 1000:1000

RUN set -o errexit -o nounset \
&& echo "Testing Groovy installation" \
&& groovy --version
70 changes: 70 additions & 0 deletions jdk21/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM eclipse-temurin:21-jdk-jammy

CMD ["groovysh"]

ENV GROOVY_HOME /opt/groovy

RUN set -o errexit -o nounset \
&& echo "Adding groovy user and group" \
&& groupadd --system --gid 1000 groovy \
&& useradd --system --gid groovy --uid 1000 --shell /bin/bash --create-home groovy \
&& mkdir --parents /home/groovy/.groovy/grapes \
&& chown --recursive groovy:groovy /home/groovy \
&& chmod --recursive 1777 /home/groovy \
\
&& echo "Symlinking root .groovy to groovy .groovy" \
&& ln --symbolic /home/groovy/.groovy /root/.groovy

VOLUME /home/groovy/.groovy/grapes

WORKDIR /home/groovy

RUN apt-get update \
&& echo "Installing build dependencies" \
&& apt-get install --yes --no-install-recommends \
dirmngr \
gnupg \
unzip \
wget \
&& rm --recursive --force /var/lib/apt/lists/*

ENV GROOVY_VERSION 4.0.15
RUN set -o errexit -o nounset \
&& echo "Downloading Groovy" \
&& wget --no-verbose --output-document=groovy.zip "https://archive.apache.org/dist/groovy/${GROOVY_VERSION}/distribution/apache-groovy-binary-${GROOVY_VERSION}.zip" \
\
&& echo "Importing keys listed in http://www.apache.org/dist/groovy/KEYS from key server" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --no-tty --keyserver keyserver.ubuntu.com --recv-keys \
7FAA0F2206DE228F0DB01AD741321490758AAD6F \
331224E1D7BE883D16E8A685825C06C827AF6B66 \
34441E504A937F43EB0DAEF96A65176A0FB1CD0B \
9A810E3B766E089FFB27C70F11B595CEDC4AEBB5 \
81CABC23EECA0790E8989B361FF96E10F0E13706 \
\
&& echo "Checking download signature" \
&& wget --no-verbose --output-document=groovy.zip.asc "https://archive.apache.org/dist/groovy/${GROOVY_VERSION}/distribution/apache-groovy-binary-${GROOVY_VERSION}.zip.asc" \
&& gpg --batch --no-tty --verify groovy.zip.asc groovy.zip \
&& rm --recursive --force "${GNUPGHOME}" \
&& rm groovy.zip.asc \
\
&& echo "Installing Groovy" \
&& unzip groovy.zip \
&& rm groovy.zip \
&& mv "groovy-${GROOVY_VERSION}" "${GROOVY_HOME}/" \
&& ln --symbolic "${GROOVY_HOME}/bin/grape" /usr/bin/grape \
&& ln --symbolic "${GROOVY_HOME}/bin/groovy" /usr/bin/groovy \
&& ln --symbolic "${GROOVY_HOME}/bin/groovyc" /usr/bin/groovyc \
&& ln --symbolic "${GROOVY_HOME}/bin/groovyConsole" /usr/bin/groovyConsole \
&& ln --symbolic "${GROOVY_HOME}/bin/groovydoc" /usr/bin/groovydoc \
&& ln --symbolic "${GROOVY_HOME}/bin/groovysh" /usr/bin/groovysh \
&& ln --symbolic "${GROOVY_HOME}/bin/java2groovy" /usr/bin/java2groovy \
\
&& echo "Editing startGroovy to include java.xml.bind module" \
&& sed --in-place 's|startGroovy ( ) {|startGroovy ( ) {\n JAVA_OPTS="$JAVA_OPTS --add-modules=ALL-SYSTEM"|' "${GROOVY_HOME}/bin/startGroovy"

USER 1000:1000

RUN set -o errexit -o nounset \
&& echo "Testing Groovy installation" \
&& groovy --version

0 comments on commit 0ea910f

Please sign in to comment.