forked from appropriate/docker-jetty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·68 lines (57 loc) · 1.61 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -ueo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
paths=( "$@" )
if [ ${#paths[@]} -eq 0 ]; then
paths=( */ )
fi
paths=( "${paths[@]%/}" )
MAVEN_METADATA_URL='https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/maven-metadata.xml'
available=( $( curl -sSL "$MAVEN_METADATA_URL" | grep -Eo '<(version)>[^<]*</\1>' | awk -F'[<>]' '{ print $3 }' | sort -Vr ) )
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
milestones=()
releaseCandidates=()
fullReleases=()
for candidate in "${available[@]}"; do
if [[ "$candidate" == "$version".* ]]; then
if [[ "$candidate" == *.M* ]]; then
milestones+=("$candidate")
elif [[ "$candidate" == *.RC* ]]; then
releaseCandidates+=("$candidate")
elif [[ "$candidate" == *.v* ]]; then
fullReleases+=("$candidate")
fi
fi
done
fullVersion=
if [ -n "${fullReleases-}" ]; then
fullVersion="$fullReleases"
elif [ -n "${releaseCandidates-}" ]; then
fullVersion="$releaseCandidates"
elif [ -n "${milestones-}" ]; then
fullVersion="$milestones"
fi
if [ -z "$fullVersion" ]; then
echo >&2 "Unable to find Jetty package for $path"
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
done