This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
forked from docker-library/wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·64 lines (52 loc) · 1.56 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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
phpVersions=( "$@" )
if [ ${#phpVersions[@]} -eq 0 ]; then
phpVersions=( php*.*/ )
fi
phpVersions=( "${phpVersions[@]%/}" )
current="$(curl -fsSL 'http://api.wordpress.org/core/version-check/1.7/' | jq -r '.offers[0].current')"
sha1="$(curl -fsSL "https://downloads.wordpress.org/release/ja/wordpress-$current.tar.gz.sha1")"
declare -A variantExtras=(
[apache]='\nRUN a2enmod rewrite expires\n'
[fpm]=''
[fpm-alpine]=''
)
declare -A variantCmds=(
[apache]='apache2-foreground'
[fpm]='php-fpm'
[fpm-alpine]='php-fpm'
)
declare -A variantBases=(
[apache]='debian'
[fpm]='debian'
[fpm-alpine]='alpine'
)
travisEnv=
for phpVersion in "${phpVersions[@]}"; do
phpVersionDir="$phpVersion"
phpVersion="${phpVersion#php}"
for variant in apache fpm fpm-alpine; do
dir="$phpVersionDir/$variant"
mkdir -p "$dir"
extras="${variantExtras[$variant]}"
cmd="${variantCmds[$variant]}"
base="${variantBases[$variant]}"
(
set -x
sed -r \
-e 's!%%WORDPRESS_VERSION%%!'"$current"'!g' \
-e 's!%%WORDPRESS_SHA1%%!'"$sha1"'!g' \
-e 's!%%PHP_VERSION%%!'"$phpVersion"'!g' \
-e 's!%%VARIANT%%!'"$variant"'!g' \
-e 's!%%VARIANT_EXTRAS%%!'"$extras"'!g' \
-e 's!%%CMD%%!'"$cmd"'!g' \
"Dockerfile-${base}.template" > "$dir/Dockerfile"
cp docker-entrypoint.sh "$dir/docker-entrypoint.sh"
)
travisEnv+='\n - VARIANT='"$dir"
done
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml