-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-canonicals.sh
executable file
·78 lines (59 loc) · 1.48 KB
/
render-canonicals.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
#!/bin/bash
set -e
tags=(latest mainline stable alpine mainline-alpine stable-alpine)
version_tags=(
# "1.21"
# "1.21-alpine"
"1.22"
"1.22-alpine"
"1.23"
"1.23-alpine"
)
supported_versions=(
"${tags[@]}"
"${version_tags[@]}"
)
S6_OVERLAY_VERSION=v3.1.1.2
force=false
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 canonical builds..."
for version in ${versions[*]}; do
local context="versions/canonicals/$version"
echo
if [[ "${force}" == "true" ]]; then
echo " ==> Removing nginx:$version template..."
rm -rf "$context"
fi
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
}
if [[ "${1}" == "--force" ]]; then
force=true
shift
fi
generate ${supported_versions[@]}