Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Issue 113 keys multi build and 103 slim JDKs #121

Merged
merged 12 commits into from
Dec 15, 2019
10 changes: 5 additions & 5 deletions 9.4-jdk13-slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM openjdk:13 AS Keys
# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh
FROM openjdk:13-jdk 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 \
Expand All @@ -25,7 +26,7 @@ RUN set -xe \
GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done

# Start a new image to import jetty and validate keys
FROM openjdk:13 AS Jetty
FROM openjdk:13-jdk AS Jetty
COPY --from=Keys /jetty-keys/ /jetty-keys/

ENV JETTY_VERSION 9.4.24.v20191120
Expand All @@ -42,8 +43,8 @@ RUN set -xe \
&& sed -i '/jetty-logging/d' etc/jetty.conf \
&& rm -fr jetty.tar.gz*

# Start a new slim image and import jetty
FROM openjdk:13-slim
# Start a new image and import jetty
FROM openjdk:13-jdk-slim
COPY --from=Jetty /usr/local/jetty/ /usr/local/jetty/

ENV JETTY_HOME /usr/local/jetty
Expand All @@ -70,4 +71,3 @@ CMD ["java","-jar","/usr/local/jetty/start.jar"]
RUN set -xe \
&& chown -R jetty:jetty "$JETTY_BASE" \
&& rm -rf /tmp/hsperfdata_root

8 changes: 4 additions & 4 deletions 9.4-jdk13/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM openjdk:13 AS Keys
# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh
FROM openjdk:13-jdk 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 \
Expand All @@ -25,7 +26,7 @@ RUN set -xe \
GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done

# Start a new image to import jetty and validate keys
FROM openjdk:13 AS Jetty
FROM openjdk:13-jdk AS Jetty
COPY --from=Keys /jetty-keys/ /jetty-keys/

ENV JETTY_VERSION 9.4.24.v20191120
Expand All @@ -43,7 +44,7 @@ RUN set -xe \
&& rm -fr jetty.tar.gz*

# Start a new image and import jetty
FROM openjdk:13
FROM openjdk:13-jdk
COPY --from=Jetty /usr/local/jetty/ /usr/local/jetty/

ENV JETTY_HOME /usr/local/jetty
Expand All @@ -70,4 +71,3 @@ CMD ["java","-jar","/usr/local/jetty/start.jar"]
RUN set -xe \
&& chown -R jetty:jetty "$JETTY_BASE" \
&& rm -rf /tmp/hsperfdata_root

6 changes: 3 additions & 3 deletions 9.4-jre11-slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM openjdk:13 AS Keys
# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh
FROM openjdk:13-jdk 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 \
Expand All @@ -25,7 +26,7 @@ RUN set -xe \
GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done

# Start a new image to import jetty and validate keys
FROM openjdk:13 AS Jetty
FROM openjdk:13-jdk AS Jetty
COPY --from=Keys /jetty-keys/ /jetty-keys/

ENV JETTY_VERSION 9.4.24.v20191120
Expand Down Expand Up @@ -70,4 +71,3 @@ CMD ["java","-jar","/usr/local/jetty/start.jar"]
RUN set -xe \
&& chown -R jetty:jetty "$JETTY_BASE" \
&& rm -rf /tmp/hsperfdata_root

6 changes: 3 additions & 3 deletions 9.4-jre11/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM openjdk:13 AS Keys
# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh
FROM openjdk:13-jdk 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 \
Expand All @@ -25,7 +26,7 @@ RUN set -xe \
GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done

# Start a new image to import jetty and validate keys
FROM openjdk:13 AS Jetty
FROM openjdk:13-jdk AS Jetty
COPY --from=Keys /jetty-keys/ /jetty-keys/

ENV JETTY_VERSION 9.4.24.v20191120
Expand Down Expand Up @@ -70,4 +71,3 @@ CMD ["java","-jar","/usr/local/jetty/start.jar"]
RUN set -xe \
&& chown -R jetty:jetty "$JETTY_BASE" \
&& rm -rf /tmp/hsperfdata_root

5 changes: 3 additions & 2 deletions 9.4-jre8/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM openjdk:13 AS Keys
# DO NOT EDIT. Edit Dockerfile-9.4 and use update.sh
FROM openjdk:13-jdk 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 \
Expand All @@ -25,7 +26,7 @@ RUN set -xe \
GNUPGHOME=/jetty-keys gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done

# Start a new image to import jetty and validate keys
FROM openjdk:13 AS Jetty
FROM openjdk:13-jdk AS Jetty
COPY --from=Keys /jetty-keys/ /jetty-keys/

ENV JETTY_VERSION 9.4.24.v20191120
Expand Down
72 changes: 72 additions & 0 deletions Dockerfile-9.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
FROM openjdk:13-jdk 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 \
# Jan Bartel <janb@mortbay.com>
AED5EE6C45D0FE8D5D1B164F27DED4BF6216DB8F \
# Jesse McConnell <jesse.mcconnell@gmail.com>
2A684B57436A81FA8706B53C61C3351A438A3B7D \
# Joakim Erdfelt <joakim.erdfelt@gmail.com>
5989BAF76217B843D66BE55B2D0E1FB8FE4B68B4 \
# Joakim Erdfelt <joakim@apache.org>
B59B67FD7904984367F931800818D9D68FB67BAC \
# Joakim Erdfelt <joakim@erdfelt.com>
BFBB21C246D7776836287A48A04E0C74ABB35FEA \
# Simone Bordet <simone.bordet@gmail.com>
8B096546B1A8F02656B15D3B1677D141BCF3584D \
# Greg Wilkins <gregw@webtide.com>
FBA2B18D238AB852DF95745C76157BDF03D0DCD6 \
# Greg Wilkins <gregw@webtide.com>
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

# Start a new image to import jetty and validate keys
FROM openjdk:13-jdk AS Jetty
COPY --from=Keys /jetty-keys/ /jetty-keys/

ENV JETTY_VERSION 9.4.24.v20191120
ENV JETTY_HOME /usr/local/jetty
ENV JETTY_TGZ_URL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$JETTY_VERSION/jetty-home-$JETTY_VERSION.tar.gz

RUN set -xe \
&& 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*

# Start a new image and import jetty
FROM openjdk:LABEL
COPY --from=Jetty /usr/local/jetty/ /usr/local/jetty/

ENV JETTY_HOME /usr/local/jetty
ENV JETTY_BASE /var/lib/jetty
ENV TMPDIR /tmp/jetty
ENV PATH $JETTY_HOME/bin:$PATH

RUN set -xe \
&& groupadd -r jetty && useradd -r -g jetty jetty \
&& mkdir -p "$JETTY_BASE" "$TMPDIR" \
&& cd $JETTY_BASE \
&& java -jar "$JETTY_HOME/start.jar" --create-startd --add-to-start="server,http,deploy,jsp,jstl,ext,resources,websocket" \
&& 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"]

RUN set -xe \
&& chown -R jetty:jetty "$JETTY_BASE" \
&& rm -rf /tmp/hsperfdata_root
13 changes: 10 additions & 3 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

set -ueo pipefail

cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

paths=( "$@" )
Expand All @@ -16,7 +14,11 @@ available=( $( curl -sSL "$MAVEN_METADATA_URL" | grep -Eo '<(version)>[^<]*</\1>

for path in "${paths[@]}"; do
version="${path%%-*}" # "9.2"
suffix="${path#*-}" # "jre7"
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=()
Expand Down Expand Up @@ -49,6 +51,11 @@ for path in "${paths[@]}"; do

if [ -d "$path" ]; then
cp docker-entrypoint.sh generate-jetty-start.sh "$path"
if [ "$version" == "9.4" ] ; 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, would it be possible to change the "templating" of Dockerfile to use build args?
The benefit would be having the Jetty full version changeable in a single place (Makefile, Travis config) without the need to modify all docker files for Jetty 9.4 for all JVM variants. Also, the version would be explicit, and there will be no dependency on parsing Maven repo metadata for latest string starting from 9.4.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think... But the practise appears to be to have all three variant dockerfiles checked in and a script to generate them if need be.

So I've kept it this way for now (plus I don't really know makefile well enough). But if I can be told it is ok to parameterized and helped with the makefile....

fi
done