forked from nginxinc/docker-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·148 lines (121 loc) · 3.43 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env bash
set -Eeuo pipefail
shopt -s nullglob
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
declare branches=(
"stable"
"mainline"
)
declare -A nginx=(
[mainline]='1.19.5'
[stable]='1.18.0'
)
defaultnjs='0.4.4'
declare -A njs=(
#[stable]='0.4.3'
)
defaultpkg='1'
declare -A pkg=(
[stable]=2
)
defaultdebian='buster'
declare -A debian=(
#[stable]='stretch'
)
defaultalpine='3.12'
declare -A alpine=(
[stable]='3.11'
)
# When we bump njs version in a stable release we don't move the tag in the
# mercurial repo. This setting allows us to specify a revision to check out
# when building alpine packages on architectures not supported by nginx.org
defaultrev='${NGINX_VERSION}-${PKG_RELEASE}'
declare -A rev=(
#[stable]='-r 500'
)
get_packages() {
local distro="$1"; shift;
local branch="$1"; shift;
local perl=
local r=
local sep=
case "$distro:$branch" in
alpine*:*)
r="r"
sep="."
;;
debian*:stable)
sep="."
;;
debian*:*)
sep="+"
;;
esac
case "$distro" in
*-perl)
perl="nginx-module-perl"
;;
esac
echo -n ' \\\n'
for p in nginx nginx-module-xslt nginx-module-geoip nginx-module-image-filter $perl; do
echo -n ' '"$p"'=${NGINX_VERSION}-'"$r"'${PKG_RELEASE} \\\n'
done
for p in nginx-module-njs; do
echo -n ' '"$p"'=${NGINX_VERSION}'"$sep"'${NJS_VERSION}-'"$r"'${PKG_RELEASE} \\'
done
}
get_packagerepo() {
local distro="${1%-perl}"; shift;
local branch="$1"; shift;
[ "$branch" = "mainline" ] && branch="$branch/" || branch=""
echo "https://nginx.org/packages/${branch}${distro}/"
}
get_packagever() {
local distro="${1%-perl}"; shift;
local branch="$1"; shift;
local suffix=
[ "${distro}" = "debian" ] && suffix="~${debianver}"
echo ${pkg[$branch]:-$defaultpkg}${suffix}
}
generated_warning() {
cat << __EOF__
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
__EOF__
}
for branch in "${branches[@]}"; do
for variant in \
alpine{,-perl} \
debian{,-perl} \
; do
echo "$branch: $variant"
dir="$branch/$variant"
variant="$(basename "$variant")"
[ -d "$dir" ] || continue
template="Dockerfile-${variant%-perl}.template"
{ generated_warning; cat "$template"; } > "$dir/Dockerfile"
debianver="${debian[$branch]:-$defaultdebian}"
alpinever="${alpine[$branch]:-$defaultalpine}"
nginxver="${nginx[$branch]}"
njsver="${njs[${branch}]:-$defaultnjs}"
pkgver="${pkg[${branch}]:-$defaultpkg}"
revver="${rev[${branch}]:-$defaultrev}"
packagerepo=$(get_packagerepo "$variant" "$branch")
packages=$(get_packages "$variant" "$branch")
packagever=$(get_packagever "$variant" "$branch")
sed -i \
-e 's,%%ALPINE_VERSION%%,'"$alpinever"',' \
-e 's,%%DEBIAN_VERSION%%,'"$debianver"',' \
-e 's,%%NGINX_VERSION%%,'"$nginxver"',' \
-e 's,%%NJS_VERSION%%,'"$njsver"',' \
-e 's,%%PKG_RELEASE%%,'"$packagever"',' \
-e 's,%%PACKAGES%%,'"$packages"',' \
-e 's,%%PACKAGEREPO%%,'"$packagerepo"',' \
-e 's,%%REVISION%%,'"$revver"',' \
"$dir/Dockerfile"
cp -a entrypoint/*.sh "$dir/"
done
done