diff --git a/9.2-jre8/Dockerfile b/9.2-jre8/Dockerfile index c9620d5..0a28aac 100644 --- a/9.2-jre8/Dockerfile +++ b/9.2-jre8/Dockerfile @@ -1,15 +1,4 @@ -FROM openjdk:8-jre - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r jetty && useradd -r -g jetty jetty - -ENV JETTY_HOME /usr/local/jetty -ENV PATH $JETTY_HOME/bin:$PATH -RUN mkdir -p "$JETTY_HOME" -WORKDIR $JETTY_HOME - -ENV JETTY_VERSION 9.2.28.v20190418 -ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/$JETTY_VERSION/jetty-distribution-$JETTY_VERSION.tar.gz +FROM openjdk:8-jre AS Keys # GPG Keys are personal keys of Jetty committers (see https://github.com/eclipse/jetty.project/blob/0607c0e66e44b9c12a62b85551da3a0edce0281e/KEYS.txt) ENV JETTY_GPG_KEYS \ @@ -31,36 +20,38 @@ ENV JETTY_GPG_KEYS \ 5C9579B3DB2E506429319AAEF33B071B29559E1E RUN set -xe \ - && curl -SL "$JETTY_TGZ_URL" -o jetty.tar.gz \ - && curl -SL "$JETTY_TGZ_URL.asc" -o jetty.tar.gz.asc \ - && export GNUPGHOME="$(mktemp -d)" \ + && mkdir /jetty-keys \ && for key in $JETTY_GPG_KEYS; do \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done \ - && gpg --batch --verify jetty.tar.gz.asc jetty.tar.gz \ - && gpgconf --kill all \ - && rm -rf "$GNUPGHOME" \ - && tar -xvf jetty.tar.gz --strip-components=1 \ - && sed -i '/jetty-logging/d' etc/jetty.conf \ - && rm -fr demo-base javadoc \ - && rm jetty.tar.gz* \ - && rm -rf /tmp/hsperfdata_root - -ENV JETTY_BASE /var/lib/jetty -RUN mkdir -p "$JETTY_BASE" -WORKDIR $JETTY_BASE + GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done -# Get the list of modules in the default start.ini and build new base with those modules -RUN modules="$(grep -- ^--module= "$JETTY_HOME/start.ini" | cut -d= -f2 | paste -d, -s)" \ - && set -xe \ - && java -jar "$JETTY_HOME/start.jar" --add-to-startd="$modules" \ - && chown -R jetty:jetty "$JETTY_BASE" \ - && rm -rf /tmp/hsperfdata_root +# Start a new image and import keys +FROM openjdk:8-jre +COPY --from=Keys /jetty-keys/ /jetty-keys/ +ENV JETTY_VERSION 9.2.29.v20191105 +ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty ENV TMPDIR /tmp/jetty +ENV PATH $JETTY_HOME/bin:$PATH +ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/$JETTY_VERSION/jetty-distribution-$JETTY_VERSION.tar.gz + RUN set -xe \ - && mkdir -p "$TMPDIR" \ - && chown -R jetty:jetty "$TMPDIR" + && groupadd -r jetty && useradd -r -g jetty jetty \ + && mkdir -p "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && cd $JETTY_HOME \ + && curl -SL "$JETTY_TGZ_URL" -o jetty.tar.gz \ + && curl -SL "$JETTY_TGZ_URL.asc" -o jetty.tar.gz.asc \ + && GNUPGHOME=/jetty-keys gpg --batch --verify jetty.tar.gz.asc jetty.tar.gz \ + && tar -xvf jetty.tar.gz --strip-components=1 \ + && sed -i '/jetty-logging/d' etc/jetty.conf \ + && rm -fr demo-base javadoc jetty.tar.gz* \ + && cd $JETTY_BASE \ + && modules="$(grep -- ^--module= "$JETTY_HOME/start.ini" | cut -d= -f2 | paste -d, -s)" \ + && java -jar "$JETTY_HOME/start.jar" --add-to-startd="$modules" \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && rm -rf /tmp/hsperfdata_root /jetty-keys +WORKDIR $JETTY_BASE COPY docker-entrypoint.sh generate-jetty-start.sh / USER jetty diff --git a/9.3-jre8/Dockerfile b/9.3-jre8/Dockerfile index 5160b66..54d4763 100644 --- a/9.3-jre8/Dockerfile +++ b/9.3-jre8/Dockerfile @@ -1,15 +1,4 @@ -FROM openjdk:8-jre - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r jetty && useradd -r -g jetty jetty - -ENV JETTY_HOME /usr/local/jetty -ENV PATH $JETTY_HOME/bin:$PATH -RUN mkdir -p "$JETTY_HOME" -WORKDIR $JETTY_HOME - -ENV JETTY_VERSION 9.3.27.v20190418 -ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/$JETTY_VERSION/jetty-distribution-$JETTY_VERSION.tar.gz +FROM openjdk:8-jre AS Keys # GPG Keys are personal keys of Jetty committers (see https://github.com/eclipse/jetty.project/blob/0607c0e66e44b9c12a62b85551da3a0edce0281e/KEYS.txt) ENV JETTY_GPG_KEYS \ @@ -31,36 +20,38 @@ ENV JETTY_GPG_KEYS \ 5C9579B3DB2E506429319AAEF33B071B29559E1E RUN set -xe \ - && curl -SL "$JETTY_TGZ_URL" -o jetty.tar.gz \ - && curl -SL "$JETTY_TGZ_URL.asc" -o jetty.tar.gz.asc \ - && export GNUPGHOME="$(mktemp -d)" \ + && mkdir /jetty-keys \ && for key in $JETTY_GPG_KEYS; do \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done \ - && gpg --batch --verify jetty.tar.gz.asc jetty.tar.gz \ - && gpgconf --kill all \ - && rm -rf "$GNUPGHOME" \ - && tar -xvf jetty.tar.gz --strip-components=1 \ - && sed -i '/jetty-logging/d' etc/jetty.conf \ - && rm -fr demo-base javadoc \ - && rm jetty.tar.gz* \ - && rm -rf /tmp/hsperfdata_root - -ENV JETTY_BASE /var/lib/jetty -RUN mkdir -p "$JETTY_BASE" -WORKDIR $JETTY_BASE + GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done -# Get the list of modules in the default start.ini and build new base with those modules -RUN modules="$(grep -- ^--module= "$JETTY_HOME/start.ini" | cut -d= -f2 | paste -d, -s)" \ - && set -xe \ - && java -jar "$JETTY_HOME/start.jar" --add-to-startd="$modules" \ - && chown -R jetty:jetty "$JETTY_BASE" \ - && rm -rf /tmp/hsperfdata_root +# Start a new image and import keys +FROM openjdk:8-jre +COPY --from=Keys /jetty-keys/ /jetty-keys/ +ENV JETTY_VERSION 9.3.28.v20191105 +ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty ENV TMPDIR /tmp/jetty +ENV PATH $JETTY_HOME/bin:$PATH +ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/$JETTY_VERSION/jetty-distribution-$JETTY_VERSION.tar.gz + RUN set -xe \ - && mkdir -p "$TMPDIR" \ - && chown -R jetty:jetty "$TMPDIR" + && groupadd -r jetty && useradd -r -g jetty jetty \ + && mkdir -p "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && cd $JETTY_HOME \ + && curl -SL "$JETTY_TGZ_URL" -o jetty.tar.gz \ + && curl -SL "$JETTY_TGZ_URL.asc" -o jetty.tar.gz.asc \ + && GNUPGHOME=/jetty-keys gpg --batch --verify jetty.tar.gz.asc jetty.tar.gz \ + && tar -xvf jetty.tar.gz --strip-components=1 \ + && sed -i '/jetty-logging/d' etc/jetty.conf \ + && rm -fr demo-base javadoc jetty.tar.gz* \ + && cd $JETTY_BASE \ + && modules="$(grep -- ^--module= "$JETTY_HOME/start.ini" | cut -d= -f2 | paste -d, -s)" \ + && java -jar "$JETTY_HOME/start.jar" --add-to-startd="$modules" \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && rm -rf /tmp/hsperfdata_root /jetty-keys +WORKDIR $JETTY_BASE COPY docker-entrypoint.sh generate-jetty-start.sh / USER jetty diff --git a/9.4-jdk13-slim/Dockerfile b/9.4-jdk13-slim/Dockerfile new file mode 100644 index 0000000..87ba9de --- /dev/null +++ b/9.4-jdk13-slim/Dockerfile @@ -0,0 +1,25 @@ +# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh +FROM openjdk:13-jdk-slim + +ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty +ENV TMPDIR /tmp/jetty +ENV PATH $JETTY_HOME/bin:$PATH + +COPY --from=jetty:9.4-jdk13 $JETTY_HOME $JETTY_HOME +COPY --from=jetty:9.4-jdk13 $JETTY_BASE $JETTY_BASE + +RUN set -xe \ + && mkdir -p "$TMPDIR" \ + && groupadd -r jetty && useradd -r -g jetty jetty \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && rm -rf /tmp/hsperfdata_root + +WORKDIR $JETTY_BASE +COPY docker-entrypoint.sh generate-jetty-start.sh / + +USER jetty +EXPOSE 8080 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["java","-jar","/usr/local/jetty/start.jar"] + diff --git a/9.4-jdk13-slim/arches b/9.4-jdk13-slim/arches new file mode 100644 index 0000000..e7b206a --- /dev/null +++ b/9.4-jdk13-slim/arches @@ -0,0 +1 @@ +amd64, arm64v8 diff --git a/9.4-jdk13-slim/docker-entrypoint.sh b/9.4-jdk13-slim/docker-entrypoint.sh new file mode 100755 index 0000000..41ccbe4 --- /dev/null +++ b/9.4-jdk13-slim/docker-entrypoint.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +set -e + +if [ "$1" = jetty.sh ]; then + if ! command -v bash >/dev/null 2>&1 ; then + cat >&2 <<- 'EOWARN' + ******************************************************************** + ERROR: bash not found. Use of jetty.sh requires bash. + ******************************************************************** + EOWARN + exit 1 + fi + cat >&2 <<- 'EOWARN' + ******************************************************************** + WARNING: Use of jetty.sh from this image is deprecated and may + be removed at some point in the future. + + See the documentation for guidance on extending this image: + https://github.com/docker-library/docs/tree/master/jetty + ******************************************************************** + EOWARN +fi + +if ! command -v -- "$1" >/dev/null 2>&1 ; then + set -- java -jar "$JETTY_HOME/start.jar" "$@" +fi + +: ${TMPDIR:=/tmp/jetty} +[ -d "$TMPDIR" ] || mkdir -p $TMPDIR 2>/dev/null + +: ${JETTY_START:=$JETTY_BASE/jetty.start} + +case "$JAVA_OPTIONS" in + *-Djava.io.tmpdir=*) ;; + *) JAVA_OPTIONS="-Djava.io.tmpdir=$TMPDIR $JAVA_OPTIONS" ;; +esac + +if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then + # this is a command to run jetty + + # check if it is a terminating command + for A in "$@" ; do + case $A in + --add-to-start* |\ + --create-files |\ + --create-startd |\ + --download |\ + --dry-run |\ + --exec-print |\ + --help |\ + --info |\ + --list-all-modules |\ + --list-classpath |\ + --list-config |\ + --list-modules* |\ + --stop |\ + --update-ini |\ + --version |\ + -v )\ + # It is a terminating command, so exec directly + JAVA="$1" + shift + exec $JAVA $JAVA_OPTIONS "$@" + esac + done + + if [ $(whoami) != "jetty" ]; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: User is $(whoami) + The user should be (re)set to 'jetty' in the Dockerfile + ******************************************************************** + EOWARN + fi + + if [ -f $JETTY_START ] ; then + if [ $JETTY_BASE/start.d -nt $JETTY_START ] ; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: The $JETTY_BASE/start.d directory has been modified since + the $JETTY_START files was generated. Either delete + the $JETTY_START file or re-run + /generate-jetty.start.sh + from a Dockerfile + ******************************************************************** + EOWARN + fi + echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start from $JETTY_START + set -- $(cat $JETTY_START) + else + # Do a jetty dry run to set the final command + JAVA="$1" + shift + $JAVA $JAVA_OPTIONS "$@" --dry-run > $JETTY_START + if [ $(egrep -v '\\$' $JETTY_START | wc -l ) -gt 1 ] ; then + # command was more than a dry-run + cat $JETTY_START \ + | awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \ + | egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration ' + exit + fi + set -- $(sed -e 's/ -Djava.io.tmpdir=[^ ]*//g' -e 's/\\$//' $JETTY_START) + fi +fi + +if [ "${1##*/}" = java -a -n "$JAVA_OPTIONS" ] ; then + JAVA="$1" + shift + set -- "$JAVA" $JAVA_OPTIONS "$@" +fi + +exec "$@" diff --git a/9.4-jdk13-slim/generate-jetty-start.sh b/9.4-jdk13-slim/generate-jetty-start.sh new file mode 100755 index 0000000..5895278 --- /dev/null +++ b/9.4-jdk13-slim/generate-jetty-start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -z "$JETTY_START" ] ; then + JETTY_START=$JETTY_BASE/jetty.start +fi +rm -f $JETTY_START +/docker-entrypoint.sh --dry-run | sed -e 's/ -Djava.io.tmpdir=[^ ]*//g' -e 's/\\$//' > $JETTY_START diff --git a/9.4-jdk13/Dockerfile b/9.4-jdk13/Dockerfile new file mode 100644 index 0000000..e23aac0 --- /dev/null +++ b/9.4-jdk13/Dockerfile @@ -0,0 +1,57 @@ +# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh +FROM openjdk:13-jdk AS Jetty94 + +ENV JETTY_VERSION 9.4.24.v20191120 +ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty +ENV TMPDIR /tmp/jetty +ENV PATH $JETTY_HOME/bin:$PATH +ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$JETTY_VERSION/jetty-home-$JETTY_VERSION.tar.gz + +# GPG Keys are personal keys of Jetty committers (see https://github.com/eclipse/jetty.project/blob/0607c0e66e44b9c12a62b85551da3a0edce0281e/KEYS.txt) +ENV JETTY_GPG_KEYS \ + # Jan Bartel + AED5EE6C45D0FE8D5D1B164F27DED4BF6216DB8F \ + # Jesse McConnell + 2A684B57436A81FA8706B53C61C3351A438A3B7D \ + # Joakim Erdfelt + 5989BAF76217B843D66BE55B2D0E1FB8FE4B68B4 \ + # Joakim Erdfelt + B59B67FD7904984367F931800818D9D68FB67BAC \ + # Joakim Erdfelt + BFBB21C246D7776836287A48A04E0C74ABB35FEA \ + # Simone Bordet + 8B096546B1A8F02656B15D3B1677D141BCF3584D \ + # Greg Wilkins + FBA2B18D238AB852DF95745C76157BDF03D0DCD6 \ + # Greg Wilkins + 5C9579B3DB2E506429319AAEF33B071B29559E1E + +RUN set -xe \ + && mkdir /jetty-keys \ + && for key in $JETTY_GPG_KEYS; do \ + GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done \ + && mkdir -p "$JETTY_HOME" \ + && cd $JETTY_HOME \ + && curl -SL "$JETTY_TGZ_URL" -o jetty.tar.gz \ + && curl -SL "$JETTY_TGZ_URL.asc" -o jetty.tar.gz.asc \ + && GNUPGHOME=/jetty-keys gpg --batch --verify jetty.tar.gz.asc jetty.tar.gz \ + && tar -xvf jetty.tar.gz --strip-components=1 \ + && sed -i '/jetty-logging/d' etc/jetty.conf \ + && rm -fr jetty.tar.gz* /jetty-keys \ + && mkdir -p "$JETTY_BASE" \ + && cd $JETTY_BASE \ + && java -jar "$JETTY_HOME/start.jar" --create-startd --add-to-start="server,http,deploy,jsp,jstl,ext,resources,websocket" \ + && mkdir -p "$TMPDIR" \ + && groupadd -r jetty && useradd -r -g jetty jetty \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && rm -rf /tmp/hsperfdata_root + +WORKDIR $JETTY_BASE +COPY docker-entrypoint.sh generate-jetty-start.sh / + +USER jetty +EXPOSE 8080 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["java","-jar","/usr/local/jetty/start.jar"] + diff --git a/9.4-jdk13/arches b/9.4-jdk13/arches new file mode 100644 index 0000000..e7b206a --- /dev/null +++ b/9.4-jdk13/arches @@ -0,0 +1 @@ +amd64, arm64v8 diff --git a/9.4-jdk13/docker-entrypoint.sh b/9.4-jdk13/docker-entrypoint.sh new file mode 100755 index 0000000..41ccbe4 --- /dev/null +++ b/9.4-jdk13/docker-entrypoint.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +set -e + +if [ "$1" = jetty.sh ]; then + if ! command -v bash >/dev/null 2>&1 ; then + cat >&2 <<- 'EOWARN' + ******************************************************************** + ERROR: bash not found. Use of jetty.sh requires bash. + ******************************************************************** + EOWARN + exit 1 + fi + cat >&2 <<- 'EOWARN' + ******************************************************************** + WARNING: Use of jetty.sh from this image is deprecated and may + be removed at some point in the future. + + See the documentation for guidance on extending this image: + https://github.com/docker-library/docs/tree/master/jetty + ******************************************************************** + EOWARN +fi + +if ! command -v -- "$1" >/dev/null 2>&1 ; then + set -- java -jar "$JETTY_HOME/start.jar" "$@" +fi + +: ${TMPDIR:=/tmp/jetty} +[ -d "$TMPDIR" ] || mkdir -p $TMPDIR 2>/dev/null + +: ${JETTY_START:=$JETTY_BASE/jetty.start} + +case "$JAVA_OPTIONS" in + *-Djava.io.tmpdir=*) ;; + *) JAVA_OPTIONS="-Djava.io.tmpdir=$TMPDIR $JAVA_OPTIONS" ;; +esac + +if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then + # this is a command to run jetty + + # check if it is a terminating command + for A in "$@" ; do + case $A in + --add-to-start* |\ + --create-files |\ + --create-startd |\ + --download |\ + --dry-run |\ + --exec-print |\ + --help |\ + --info |\ + --list-all-modules |\ + --list-classpath |\ + --list-config |\ + --list-modules* |\ + --stop |\ + --update-ini |\ + --version |\ + -v )\ + # It is a terminating command, so exec directly + JAVA="$1" + shift + exec $JAVA $JAVA_OPTIONS "$@" + esac + done + + if [ $(whoami) != "jetty" ]; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: User is $(whoami) + The user should be (re)set to 'jetty' in the Dockerfile + ******************************************************************** + EOWARN + fi + + if [ -f $JETTY_START ] ; then + if [ $JETTY_BASE/start.d -nt $JETTY_START ] ; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: The $JETTY_BASE/start.d directory has been modified since + the $JETTY_START files was generated. Either delete + the $JETTY_START file or re-run + /generate-jetty.start.sh + from a Dockerfile + ******************************************************************** + EOWARN + fi + echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start from $JETTY_START + set -- $(cat $JETTY_START) + else + # Do a jetty dry run to set the final command + JAVA="$1" + shift + $JAVA $JAVA_OPTIONS "$@" --dry-run > $JETTY_START + if [ $(egrep -v '\\$' $JETTY_START | wc -l ) -gt 1 ] ; then + # command was more than a dry-run + cat $JETTY_START \ + | awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \ + | egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration ' + exit + fi + set -- $(sed -e 's/ -Djava.io.tmpdir=[^ ]*//g' -e 's/\\$//' $JETTY_START) + fi +fi + +if [ "${1##*/}" = java -a -n "$JAVA_OPTIONS" ] ; then + JAVA="$1" + shift + set -- "$JAVA" $JAVA_OPTIONS "$@" +fi + +exec "$@" diff --git a/9.4-jdk13/generate-jetty-start.sh b/9.4-jdk13/generate-jetty-start.sh new file mode 100755 index 0000000..5895278 --- /dev/null +++ b/9.4-jdk13/generate-jetty-start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -z "$JETTY_START" ] ; then + JETTY_START=$JETTY_BASE/jetty.start +fi +rm -f $JETTY_START +/docker-entrypoint.sh --dry-run | sed -e 's/ -Djava.io.tmpdir=[^ ]*//g' -e 's/\\$//' > $JETTY_START diff --git a/9.4-jre11-slim/Dockerfile b/9.4-jre11-slim/Dockerfile new file mode 100644 index 0000000..cef2d9f --- /dev/null +++ b/9.4-jre11-slim/Dockerfile @@ -0,0 +1,25 @@ +# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh +FROM openjdk:11-jre-slim + +ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty +ENV TMPDIR /tmp/jetty +ENV PATH $JETTY_HOME/bin:$PATH + +COPY --from=jetty:9.4-jdk13 $JETTY_HOME $JETTY_HOME +COPY --from=jetty:9.4-jdk13 $JETTY_BASE $JETTY_BASE + +RUN set -xe \ + && mkdir -p "$TMPDIR" \ + && groupadd -r jetty && useradd -r -g jetty jetty \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && rm -rf /tmp/hsperfdata_root + +WORKDIR $JETTY_BASE +COPY docker-entrypoint.sh generate-jetty-start.sh / + +USER jetty +EXPOSE 8080 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["java","-jar","/usr/local/jetty/start.jar"] + diff --git a/9.4-jre11-slim/arches b/9.4-jre11-slim/arches new file mode 100644 index 0000000..e7b206a --- /dev/null +++ b/9.4-jre11-slim/arches @@ -0,0 +1 @@ +amd64, arm64v8 diff --git a/9.4-jre11-slim/docker-entrypoint.sh b/9.4-jre11-slim/docker-entrypoint.sh new file mode 100755 index 0000000..41ccbe4 --- /dev/null +++ b/9.4-jre11-slim/docker-entrypoint.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +set -e + +if [ "$1" = jetty.sh ]; then + if ! command -v bash >/dev/null 2>&1 ; then + cat >&2 <<- 'EOWARN' + ******************************************************************** + ERROR: bash not found. Use of jetty.sh requires bash. + ******************************************************************** + EOWARN + exit 1 + fi + cat >&2 <<- 'EOWARN' + ******************************************************************** + WARNING: Use of jetty.sh from this image is deprecated and may + be removed at some point in the future. + + See the documentation for guidance on extending this image: + https://github.com/docker-library/docs/tree/master/jetty + ******************************************************************** + EOWARN +fi + +if ! command -v -- "$1" >/dev/null 2>&1 ; then + set -- java -jar "$JETTY_HOME/start.jar" "$@" +fi + +: ${TMPDIR:=/tmp/jetty} +[ -d "$TMPDIR" ] || mkdir -p $TMPDIR 2>/dev/null + +: ${JETTY_START:=$JETTY_BASE/jetty.start} + +case "$JAVA_OPTIONS" in + *-Djava.io.tmpdir=*) ;; + *) JAVA_OPTIONS="-Djava.io.tmpdir=$TMPDIR $JAVA_OPTIONS" ;; +esac + +if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then + # this is a command to run jetty + + # check if it is a terminating command + for A in "$@" ; do + case $A in + --add-to-start* |\ + --create-files |\ + --create-startd |\ + --download |\ + --dry-run |\ + --exec-print |\ + --help |\ + --info |\ + --list-all-modules |\ + --list-classpath |\ + --list-config |\ + --list-modules* |\ + --stop |\ + --update-ini |\ + --version |\ + -v )\ + # It is a terminating command, so exec directly + JAVA="$1" + shift + exec $JAVA $JAVA_OPTIONS "$@" + esac + done + + if [ $(whoami) != "jetty" ]; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: User is $(whoami) + The user should be (re)set to 'jetty' in the Dockerfile + ******************************************************************** + EOWARN + fi + + if [ -f $JETTY_START ] ; then + if [ $JETTY_BASE/start.d -nt $JETTY_START ] ; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: The $JETTY_BASE/start.d directory has been modified since + the $JETTY_START files was generated. Either delete + the $JETTY_START file or re-run + /generate-jetty.start.sh + from a Dockerfile + ******************************************************************** + EOWARN + fi + echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start from $JETTY_START + set -- $(cat $JETTY_START) + else + # Do a jetty dry run to set the final command + JAVA="$1" + shift + $JAVA $JAVA_OPTIONS "$@" --dry-run > $JETTY_START + if [ $(egrep -v '\\$' $JETTY_START | wc -l ) -gt 1 ] ; then + # command was more than a dry-run + cat $JETTY_START \ + | awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \ + | egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration ' + exit + fi + set -- $(sed -e 's/ -Djava.io.tmpdir=[^ ]*//g' -e 's/\\$//' $JETTY_START) + fi +fi + +if [ "${1##*/}" = java -a -n "$JAVA_OPTIONS" ] ; then + JAVA="$1" + shift + set -- "$JAVA" $JAVA_OPTIONS "$@" +fi + +exec "$@" diff --git a/9.4-jre11-slim/generate-jetty-start.sh b/9.4-jre11-slim/generate-jetty-start.sh new file mode 100755 index 0000000..5895278 --- /dev/null +++ b/9.4-jre11-slim/generate-jetty-start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -z "$JETTY_START" ] ; then + JETTY_START=$JETTY_BASE/jetty.start +fi +rm -f $JETTY_START +/docker-entrypoint.sh --dry-run | sed -e 's/ -Djava.io.tmpdir=[^ ]*//g' -e 's/\\$//' > $JETTY_START diff --git a/9.4-jre11/Dockerfile b/9.4-jre11/Dockerfile index 9f0229a..17032c1 100644 --- a/9.4-jre11/Dockerfile +++ b/9.4-jre11/Dockerfile @@ -1,65 +1,25 @@ +# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh FROM openjdk:11-jre -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r jetty && useradd -r -g jetty jetty - ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty +ENV TMPDIR /tmp/jetty ENV PATH $JETTY_HOME/bin:$PATH -RUN mkdir -p "$JETTY_HOME" -WORKDIR $JETTY_HOME - -ENV JETTY_VERSION 9.4.24.v20191120 -ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$JETTY_VERSION/jetty-home-$JETTY_VERSION.tar.gz -# GPG Keys are personal keys of Jetty committers (see https://github.com/eclipse/jetty.project/blob/0607c0e66e44b9c12a62b85551da3a0edce0281e/KEYS.txt) -ENV JETTY_GPG_KEYS \ - # Jan Bartel - AED5EE6C45D0FE8D5D1B164F27DED4BF6216DB8F \ - # Jesse McConnell - 2A684B57436A81FA8706B53C61C3351A438A3B7D \ - # Joakim Erdfelt - 5989BAF76217B843D66BE55B2D0E1FB8FE4B68B4 \ - # Joakim Erdfelt - B59B67FD7904984367F931800818D9D68FB67BAC \ - # Joakim Erdfelt - BFBB21C246D7776836287A48A04E0C74ABB35FEA \ - # Simone Bordet - 8B096546B1A8F02656B15D3B1677D141BCF3584D \ - # Greg Wilkins - FBA2B18D238AB852DF95745C76157BDF03D0DCD6 \ - # Greg Wilkins - 5C9579B3DB2E506429319AAEF33B071B29559E1E +COPY --from=jetty:9.4-jdk13 $JETTY_HOME $JETTY_HOME +COPY --from=jetty:9.4-jdk13 $JETTY_BASE $JETTY_BASE RUN set -xe \ - && curl -SL "$JETTY_TGZ_URL" -o jetty.tar.gz \ - && curl -SL "$JETTY_TGZ_URL.asc" -o jetty.tar.gz.asc \ - && export GNUPGHOME="$(mktemp -d)" \ - && for key in $JETTY_GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done \ - && gpg --batch --verify jetty.tar.gz.asc jetty.tar.gz \ - && rm -rf "$GNUPGHOME" \ - && tar -xvf jetty.tar.gz --strip-components=1 \ - && sed -i '/jetty-logging/d' etc/jetty.conf \ - && rm jetty.tar.gz* \ + && mkdir -p "$TMPDIR" \ + && groupadd -r jetty && useradd -r -g jetty jetty \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ && rm -rf /tmp/hsperfdata_root -ENV JETTY_BASE /var/lib/jetty -RUN mkdir -p "$JETTY_BASE" WORKDIR $JETTY_BASE - -RUN set -xe \ - && java -jar "$JETTY_HOME/start.jar" --create-startd --add-to-start="server,http,deploy,jsp,jstl,ext,resources,websocket" \ - && chown -R jetty:jetty "$JETTY_BASE" \ - && rm -rf /tmp/hsperfdata_root - -ENV TMPDIR /tmp/jetty -RUN set -xe \ - && mkdir -p "$TMPDIR" \ - && chown -R jetty:jetty "$TMPDIR" - COPY docker-entrypoint.sh generate-jetty-start.sh / USER jetty EXPOSE 8080 ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["java","-jar","/usr/local/jetty/start.jar"] + diff --git a/9.4-jre8/Dockerfile b/9.4-jre8/Dockerfile index 3cff184..3628ee7 100644 --- a/9.4-jre8/Dockerfile +++ b/9.4-jre8/Dockerfile @@ -1,66 +1,25 @@ +# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh FROM openjdk:8-jre -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r jetty && useradd -r -g jetty jetty - ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty +ENV TMPDIR /tmp/jetty ENV PATH $JETTY_HOME/bin:$PATH -RUN mkdir -p "$JETTY_HOME" -WORKDIR $JETTY_HOME - -ENV JETTY_VERSION 9.4.24.v20191120 -ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$JETTY_VERSION/jetty-home-$JETTY_VERSION.tar.gz -# GPG Keys are personal keys of Jetty committers (see https://github.com/eclipse/jetty.project/blob/0607c0e66e44b9c12a62b85551da3a0edce0281e/KEYS.txt) -ENV JETTY_GPG_KEYS \ - # Jan Bartel - AED5EE6C45D0FE8D5D1B164F27DED4BF6216DB8F \ - # Jesse McConnell - 2A684B57436A81FA8706B53C61C3351A438A3B7D \ - # Joakim Erdfelt - 5989BAF76217B843D66BE55B2D0E1FB8FE4B68B4 \ - # Joakim Erdfelt - B59B67FD7904984367F931800818D9D68FB67BAC \ - # Joakim Erdfelt - BFBB21C246D7776836287A48A04E0C74ABB35FEA \ - # Simone Bordet - 8B096546B1A8F02656B15D3B1677D141BCF3584D \ - # Greg Wilkins - FBA2B18D238AB852DF95745C76157BDF03D0DCD6 \ - # Greg Wilkins - 5C9579B3DB2E506429319AAEF33B071B29559E1E +COPY --from=jetty:9.4-jdk13 $JETTY_HOME $JETTY_HOME +COPY --from=jetty:9.4-jdk13 $JETTY_BASE $JETTY_BASE RUN set -xe \ - && curl -SL "$JETTY_TGZ_URL" -o jetty.tar.gz \ - && curl -SL "$JETTY_TGZ_URL.asc" -o jetty.tar.gz.asc \ - && export GNUPGHOME="$(mktemp -d)" \ - && for key in $JETTY_GPG_KEYS; do \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done \ - && gpg --batch --verify jetty.tar.gz.asc jetty.tar.gz \ - && gpgconf --kill all \ - && rm -rf "$GNUPGHOME" \ - && tar -xvf jetty.tar.gz --strip-components=1 \ - && sed -i '/jetty-logging/d' etc/jetty.conf \ - && rm jetty.tar.gz* \ + && mkdir -p "$TMPDIR" \ + && groupadd -r jetty && useradd -r -g jetty jetty \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ && rm -rf /tmp/hsperfdata_root -ENV JETTY_BASE /var/lib/jetty -RUN mkdir -p "$JETTY_BASE" WORKDIR $JETTY_BASE - -RUN set -xe \ - && java -jar "$JETTY_HOME/start.jar" --create-startd --add-to-start="server,http,deploy,jsp,jstl,ext,resources,websocket" \ - && chown -R jetty:jetty "$JETTY_BASE" \ - && rm -rf /tmp/hsperfdata_root - -ENV TMPDIR /tmp/jetty -RUN set -xe \ - && mkdir -p "$TMPDIR" \ - && chown -R jetty:jetty "$TMPDIR" - COPY docker-entrypoint.sh generate-jetty-start.sh / USER jetty EXPOSE 8080 ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["java","-jar","/usr/local/jetty/start.jar"] + diff --git a/Dockerfile-9.4 b/Dockerfile-9.4 new file mode 100644 index 0000000..4433218 --- /dev/null +++ b/Dockerfile-9.4 @@ -0,0 +1,24 @@ +FROM openjdk:LABEL + +ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty +ENV TMPDIR /tmp/jetty +ENV PATH $JETTY_HOME/bin:$PATH + +COPY --from=jetty:9.4-jdk13 $JETTY_HOME $JETTY_HOME +COPY --from=jetty:9.4-jdk13 $JETTY_BASE $JETTY_BASE + +RUN set -xe \ + && mkdir -p "$TMPDIR" \ + && groupadd -r jetty && useradd -r -g jetty jetty \ + && chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" \ + && rm -rf /tmp/hsperfdata_root + +WORKDIR $JETTY_BASE +COPY docker-entrypoint.sh generate-jetty-start.sh / + +USER jetty +EXPOSE 8080 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["java","-jar","/usr/local/jetty/start.jar"] + diff --git a/Makefile b/Makefile index f4fb093..2639afc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSIONS = $(foreach df,$(wildcard */alpine/Dockerfile */Dockerfile),$(df:%/Dockerfile=%)) +VERSIONS = $(foreach df,$(wildcard */Dockerfile),$(df:%/Dockerfile=%)) all: build @@ -10,6 +10,11 @@ $1: endef $(foreach version,$(VERSIONS),$(eval $(call jetty-version,$(version)))) +9.4-jdk13-slim: 9.4-jdk13 +9.4-jre11: 9.4-jdk13 +9.4-jre11-slim: 9.4-jdk13 +9.4-jre8: 9.4-jdk13 + update: docker run --rm -v $$(pwd):/work -w /work buildpack-deps ./update.sh diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 038c13a..e4c1122 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -4,15 +4,14 @@ shopt -s globstar declare -A aliases aliases=( - [9.2-jre7]='jre7' - [9.4-jre8]='latest jre8' + [9.4-jdk13]='latest jdk13' ) -defaultJdk="jre8" +defaultJdk="jdk13" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" -paths=( **/*/Dockerfile ) -paths=( $( printf '%s\n' "${paths[@]%/Dockerfile}" | sort -t/ -k 1,1Vr -k 2,2 ) ) +paths=( **/Dockerfile ) +paths=( $( printf '%s\n' "${paths[@]%/Dockerfile}" | sort -k 1.1,1.3Vr -k 1,8 ) ) url='https://github.com/appropriate/docker-jetty.git' cat <<-EOH @@ -37,16 +36,13 @@ addTag() { for path in "${paths[@]}"; do tags=() - directory="$path" - commit="$(git log -1 --format='format:%H' -- "$directory")" - version="$(grep -m1 'ENV JETTY_VERSION ' "$directory/Dockerfile" | cut -d' ' -f3)" + commit="$(git log -1 --format='format:%H' -- "$path")" - # Determine if this is a variant image - if [[ "$path" = */* ]]; then - variant=${path#*/} # "alpine" - path=${path%/*} + major="${path%%-*}" # "9.2" + if [[ "$major" == "9.4" ]]; then + version="$(grep -m1 'ENV JETTY_VERSION ' "9.4-jdk13/Dockerfile" | cut -d' ' -f3)" else - variant='' + version="$(grep -m1 'ENV JETTY_VERSION ' "$path/Dockerfile" | cut -d' ' -f3)" fi # Determine the JDK @@ -67,28 +63,23 @@ for path in "${paths[@]}"; do fi # Output ${versionAliases[@]} without JDK - # e.g. 9.2.10, 9.2, 9, 9.3-alpine + # e.g. 9.2.10, 9.2, 9 if [ "$jdk" = "$defaultJdk" ]; then for va in "${versionAliases[@]}"; do - addTag "$va${variant:+-$variant}" + addTag "$va" done fi # Output ${versionAliases[@]} with JDK suffixes - # e.g. 9.2.10-jre7, 9.2-jre7, 9-jre7, 9-jre8-alpine + # e.g. 9.2.10-jre7, 9.2-jre7, 9-jre7, 9-jre11-slim for va in "${versionAliases[@]}"; do - addTag "$va-$jdk${variant:+-$variant}" + addTag "$va-$jdk" done # Output custom aliases - # e.g. latest, jre7, jre8, alpine + # e.g. latest, jre7, jre8 if [ ${#aliases[$path]} -gt 0 ]; then for va in ${aliases[$path]}; do - if [ ! -z "$variant" -a "$va" = 'latest' ]; then - va="$variant" - else - va="$va${variant:+-$variant}" - fi addTag "$va" done fi @@ -96,8 +87,8 @@ for path in "${paths[@]}"; do cat <<-EOE Tags:$(IFS=, ; echo "${tags[*]/#/ }") - Architectures: $(< "$directory/arches") - Directory: $directory + Architectures: $(< "$path/arches") + Directory: $path GitCommit: $commit EOE done diff --git a/update.sh b/update.sh index 33f9c52..8d0cdd0 100755 --- a/update.sh +++ b/update.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -ueo pipefail - cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" paths=( "$@" ) @@ -16,14 +14,11 @@ available=( $( curl -sSL "$MAVEN_METADATA_URL" | grep -Eo '<(version)>[^<]* for path in "${paths[@]}"; do version="${path%%-*}" # "9.2" - suffix="${path#*-}" # "jre7" - - baseImage='openjdk' - case "$suffix" in - jre*|jdk*) - baseImage+=":${suffix:3}-${suffix:0:3}" # ":7-jre" - ;; - esac + jvm="${path#*-}" # "jre11-slim" + disto=$(expr "$jvm" : '\(j..\)[0-9].*') # jre + variant=$(expr "$jvm" : '.*-\(.*\)') # slim + release=$(expr "$jvm" : 'j..\([0-9][0-9]*\).*') # 11 + label=${release}-${disto}${variant:+-$variant} # 11-jre-slim milestones=() releaseCandidates=() @@ -54,15 +49,13 @@ for path in "${paths[@]}"; do exit 1 fi - for variant in alpine ''; do - [ -d "$path/$variant" ] || continue - ( - set -x - cp docker-entrypoint.sh generate-jetty-start.sh "$path/$variant" - sed -ri ' - s/^(FROM) .*/\1 '"$baseImage${variant:+-$variant}"'/; - s/^(ENV JETTY_VERSION) .*/\1 '"$fullVersion"'/; - ' "$path/$variant/Dockerfile" - ) - done + if [ -d "$path" ]; then + cp docker-entrypoint.sh generate-jetty-start.sh "$path" + if [ "$version" == "9.4" -a "$jvm" != "jdk13" ] ; then + echo '# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh' > "$path"/Dockerfile + cat Dockerfile-9.4 >> "$path"/Dockerfile + sed -ri 's/^(FROM openjdk:)LABEL/\1'"$label"'/; ' "$path/Dockerfile" + fi + sed -ri 's/^(ENV JETTY_VERSION) .*/\1 '"$fullVersion"'/; ' "$path/Dockerfile" + fi done