-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-fixed.sh
executable file
·110 lines (86 loc) · 2.17 KB
/
render-fixed.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
#!/bin/bash
set -e
# v1.21
version_1_21=(
"1.21.3"
"1.21.4"
"1.21.5"
"1.21.6"
)
# v1.22
version_1_22=(
"1.22.0"
)
# v1.23
version_1_23=(
"1.23.0"
"1.23.1"
)
supported_versions=(
# "${version_1_21[@]}"
"${version_1_22[@]}"
"${version_1_23[@]}"
)
# S6_OVERLAY_VERSION=v2.2.0.1 # v1.21
S6_OVERLAY_VERSION=v3.1.1.2 # v1.22, v1.23
render() {
sedStr=""
sedStr+="s!%%S6_NGINX_VERSION%%!$1!g;"
sedStr+="s!%%S6_OVERLAY_VERSION%%!$2!g;"
sed -r "$sedStr" Dockerfile.template
}
render_readme() {
sedStr=""
sedStr+="s!%%S6_NGINX_VERSION%%!$1!g;"
sedStr+="s!%%S6_OVERLAY_VERSION%%!$2!g;"
sed -r "$sedStr" README.template.md
}
generate() {
local versions=$@
echo "Rendering fixed builds..."
for version in ${versions[*]}; do
local context="versions/fixed/${version}"
echo
echo " ==> Genetating nginx:${version} build..."
# If exist, skip
if [ -d "$context" ]; then
echo " ==> [Skip] Template for nginx:${version} already exists!"
continue;
fi
mkdir -p "$context"
cp -r rootfs "$context"
echo " [+] Generating Dockerfile"
render_readme "${version}" "${S6_OVERLAY_VERSION}" > "$context/README.md"
echo " [+] Generating README.md"
render ${version} "${S6_OVERLAY_VERSION}" > "$context/Dockerfile"
echo " [+] [Done] nginx:${version} generated!"
done
}
generate_alpine() {
local versions=$@
for version in ${versions[*]}; do
local ver=${version}-alpine
local context="versions/fixed/$ver"
echo " ==> Genetating nginx:$ver build..."
# If exist, skip
if [ -d "$context" ]; then
echo " ==> [Skip] Template for nginx:$ver already exists!"
echo
continue;
fi
mkdir -p "$context"
cp -r rootfs "$context"
echo " [+] Generating Dockerfile"
render_readme "$ver" "${S6_OVERLAY_VERSION}" > "$context/README.md"
echo " [+] Generating README.md"
render "$ver" "${S6_OVERLAY_VERSION}" > "$context/Dockerfile"
echo " [+] [Done] nginx:$ver generated!"
echo
done
}
if [[ -z "${supported_versions[@]}" ]]; then
echo "Please specify versions to render."
exit 1
fi
generate ${supported_versions[@]}
generate_alpine ${supported_versions[@]}