forked from docker-library/rabbitmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply-templates.sh
executable file
·72 lines (56 loc) · 1.64 KB
/
apply-templates.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
69
70
71
72
#!/usr/bin/env bash
set -Eeuo pipefail
[ -f versions.json ] # run "versions.sh" first
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
jqt='.jq-template.awk'
if [ -n "${BASHBREW_SCRIPTS:-}" ]; then
jqt="$BASHBREW_SCRIPTS/jq-template.awk"
elif [ "$BASH_SOURCE" -nt "$jqt" ]; then
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/5f0c26381fb7cc78b2d217d58007800bdcfbcfa1/scripts/jq-template.awk'
fi
if [ "$#" -eq 0 ]; then
versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)"
eval "set -- $versions"
fi
generated_warning() {
cat <<-EOH
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
EOH
}
for version; do
export version
if jq -e '.[env.version] | not' versions.json > /dev/null; then
echo "deleting $version ..."
rm -rf "$version"
continue
fi
for variant in alpine ubuntu; do
export variant
echo "processing $version/$variant ..."
{
generated_warning
gawk -f "$jqt" "Dockerfile-$variant.template"
} > "$version/$variant/Dockerfile"
entrypoint='docker-entrypoint.sh'
rcVersion="${version%-rc}"
if [ "$rcVersion" = '3.8' ]; then
entrypoint="docker-entrypoint-$rcVersion.sh"
fi
cp -a "$entrypoint" "$version/$variant/docker-entrypoint.sh"
if [ "$rcVersion" != '3.8' ]; then
cp 10-default-guest-user.conf "$version/$variant/"
fi
if [ "$variant" = 'alpine' ]; then
sed -i -e 's/gosu/su-exec/g' "$version/$variant/docker-entrypoint.sh"
fi
echo "processing $version/$variant/management ..."
{
generated_warning
gawk -f "$jqt" Dockerfile-management.template
} > "$version/$variant/management/Dockerfile"
done
done