-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
executable file
·54 lines (44 loc) · 1.3 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
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
pythonVersion="3.7.4-buster"
generated_warning() {
cat <<-EOH
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
EOH
}
for version in "${versions[@]}"; do
# Declare directory and make sure it is made.
dir="${version}"
mkdir -p "${dir}"
# Declare the entrypoint.
entrypoint='docker-entrypoint.sh'
# Prepend warning to Dockerfile.
{ generated_warning; cat Dockerfile.tmpl; } > "${dir}/Dockerfile"
# Update Dockerfile with veriables.
sed -ri \
-e 's!%%PYTHON_VERSION%%!'"${pythonVersion}"'!g' \
-e 's!%%DJANGO_VERSION%%!'"${version}"'!g' \
"${dir}/Dockerfile"
# Known issue with Python 3.7 and any Django version before 1.11.17.
if [ "${version}" = '1.11' ]; then
version='1.11.17'
fi
# Use requirements.txt template to generate requirements.txt for build.
sed -r \
-e 's!%%PYTHON_VERSION%%!'"${pythonVersion}"'!g' \
-e 's!%%DJANGO_VERSION%%!'"${version}"'!g' \
"requirements-txt.tmpl" > "${dir}/requirements.txt"
# Copy entrypoint for build.
cp -a "${entrypoint}" "${dir}/docker-entrypoint.sh"
cp -a "wait-for-it.sh" "${dir}/wait-for-it.sh"
done