2018-05-24 21:20:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
declare -A php_version=(
|
2020-06-15 00:30:25 +02:00
|
|
|
[default]='7.3'
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
declare -A cmd=(
|
2020-06-15 00:30:25 +02:00
|
|
|
[apache]='apache2-foreground'
|
|
|
|
[fpm]='php-fpm'
|
|
|
|
[fpm-alpine]='php-fpm'
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
declare -A base=(
|
2020-06-15 00:30:25 +02:00
|
|
|
[apache]='debian'
|
|
|
|
[fpm]='debian'
|
|
|
|
[fpm-alpine]='alpine'
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
declare -A extras=(
|
2020-06-15 00:30:25 +02:00
|
|
|
[apache]='\nRUN set -ex;\\\n a2enmod rewrite remoteip ;\\\n {\\\n echo RemoteIPHeader X-Real-IP ;\\\n echo RemoteIPTrustedProxy 10.0.0.0/8 ;\\\n echo RemoteIPTrustedProxy 172.16.0.0/12 ;\\\n echo RemoteIPTrustedProxy 192.168.0.0/16 ;\\\n } > /etc/apache2/conf-available/remoteip.conf;\\\n a2enconf remoteip'
|
|
|
|
[fpm]=''
|
|
|
|
[fpm-alpine]=''
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
2019-11-26 21:47:40 +01:00
|
|
|
declare -A entrypoints=(
|
|
|
|
[stable]='entrypoint.sh'
|
|
|
|
[develop]='entrypoint-dev.sh'
|
|
|
|
)
|
|
|
|
|
2020-03-08 20:47:56 +01:00
|
|
|
# Only for debian variant
|
2020-03-09 21:39:50 +01:00
|
|
|
tini_version="$(
|
2020-06-15 00:30:25 +02:00
|
|
|
git ls-remote --tags https://github.com/krallin/tini.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -vE -- '.pre' \
|
|
|
|
| sed -E 's/^v//' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
2020-03-09 21:39:50 +01:00
|
|
|
)"
|
2020-03-08 20:47:56 +01:00
|
|
|
|
2019-06-23 02:24:02 +02:00
|
|
|
apcu_version="$(
|
2020-06-15 00:30:25 +02:00
|
|
|
git ls-remote --tags https://github.com/krakjoe/apcu.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -vE -- '-rc|-b' \
|
|
|
|
| sed -E 's/^v//' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
2019-06-23 02:24:02 +02:00
|
|
|
)"
|
|
|
|
|
|
|
|
memcached_version="$(
|
2020-06-15 00:30:25 +02:00
|
|
|
git ls-remote --tags https://github.com/php-memcached-dev/php-memcached.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -vE -- '-rc|-b' \
|
|
|
|
| sed -E 's/^[rv]//' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
2019-06-23 02:24:02 +02:00
|
|
|
)"
|
|
|
|
|
|
|
|
redis_version="$(
|
2020-06-15 00:30:25 +02:00
|
|
|
git ls-remote --tags https://github.com/phpredis/phpredis.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -viE '[a-z]' \
|
|
|
|
| tr -d '^{}' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
2019-06-23 02:24:02 +02:00
|
|
|
)"
|
|
|
|
|
|
|
|
imagick_version="$(
|
2020-06-15 00:30:25 +02:00
|
|
|
git ls-remote --tags https://github.com/mkoppanen/imagick.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -viE '[a-z]' \
|
|
|
|
| tr -d '^{}' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
2019-06-23 02:24:02 +02:00
|
|
|
)"
|
|
|
|
|
2018-05-24 21:20:25 +02:00
|
|
|
declare -A pecl_versions=(
|
2020-06-15 00:30:25 +02:00
|
|
|
[APCu]="$apcu_version"
|
|
|
|
[memcached]="$memcached_version"
|
|
|
|
[redis]="$redis_version"
|
|
|
|
[imagick]="$imagick_version"
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
declare -A install_extras=(
|
2020-07-12 22:20:07 +02:00
|
|
|
['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \\\n tar -xzf friendica.tar.gz -C /usr/src/; \\\n rm friendica.tar.gz; \\\n mv -f /usr/src/friendica-full-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n curl -fsSL -o friendica_addons.tar.gz \\\n "https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \\\n mkdir -p /usr/src/friendica/proxy; \\\n mkdir -p /usr/src/friendica/addon; \\\n tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica_addons.tar.gz;'
|
2020-06-15 00:30:25 +02:00
|
|
|
['develop']=''
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
variants=(
|
2020-06-15 00:30:25 +02:00
|
|
|
apache
|
|
|
|
fpm
|
|
|
|
fpm-alpine
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
versions=(
|
2020-07-12 21:46:40 +02:00
|
|
|
2020.07
|
|
|
|
2020.09-dev
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
travisEnv=
|
|
|
|
travisEnvAmd64=
|
|
|
|
|
|
|
|
function create_variant() {
|
2020-06-15 00:30:25 +02:00
|
|
|
dockerName=${1,,}
|
|
|
|
dir="$dockerName/$variant"
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
# Create the version+variant directory with a Dockerfile.
|
|
|
|
mkdir -p "$dir"
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
template="Dockerfile-${base[$variant]}.template"
|
|
|
|
echo "# DO NOT EDIT: created by update.sh from $template" > "$dir/Dockerfile"
|
|
|
|
cat "$template" >> "$dir/Dockerfile"
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
# Check which installation typ we need. If develop, the source will get downloaded by git.
|
|
|
|
install_type='stable'
|
|
|
|
if [[ "${1,,}" == *-dev ]] || [[ "${1,,}" == *-rc ]]; then
|
|
|
|
install_type='develop'
|
|
|
|
fi
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
echo "updating $1 [$install_type] $variant"
|
|
|
|
|
|
|
|
# Replace the variables.
|
|
|
|
sed -ri -e '
|
|
|
|
s/%%PHP_VERSION%%/'"${php_version[$version]-${php_version[default]}}"'/g;
|
|
|
|
s/%%VARIANT%%/'"$variant"'/g;
|
|
|
|
s/%%VERSION%%/'"$1"'/g;
|
|
|
|
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
|
|
|
s|%%VARIANT_EXTRAS%%|'"${extras[$variant]}"'|g;
|
|
|
|
s|%%INSTALL_EXTRAS%%|'"${install_extras[$install_type]}"'|g;
|
|
|
|
s/%%APCU_VERSION%%/'"${pecl_versions[APCu]}"'/g;
|
|
|
|
s/%%IMAGICK_VERSION%%/'"${pecl_versions[imagick]}"'/g;
|
|
|
|
s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g;
|
|
|
|
s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g;
|
|
|
|
s/%%ENTRYPOINT%%/'"${entrypoints[$install_type]}"'/g;
|
|
|
|
s/%%TINI_VERSION%%/'"${tini_version}"'/g;
|
|
|
|
' "$dir/Dockerfile"
|
|
|
|
|
|
|
|
for name in entrypoint cron; do
|
|
|
|
cp "docker-$name.sh" "$dir/$name.sh"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $install_type == "develop" ]]; then
|
|
|
|
cp "docker-entrypoint-dev.sh" "$dir/entrypoint-dev.sh"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp upgrade.exclude "$dir/"
|
|
|
|
|
|
|
|
cp -rT .config "$dir/config"
|
|
|
|
|
|
|
|
travisEnvAmd64='\n - env: VERSION='"$dockerName"' VARIANT='"$variant"' ARCH=amd64'"$travisEnvAmd64"
|
|
|
|
for arch in i386 amd64; do
|
|
|
|
travisEnv='\n - env: VERSION='"$dockerName"' VARIANT='"$variant"' ARCH='"$arch$travisEnv"
|
|
|
|
done
|
2018-05-24 21:20:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\(\.\|\-\)[[:digit:]]\+\(-rc\|-dev\)\?' -exec rm -r '{}' \;
|
|
|
|
|
|
|
|
for version in "${versions[@]}"; do
|
2020-06-15 00:30:25 +02:00
|
|
|
for variant in "${variants[@]}"; do
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
create_variant "$version"
|
|
|
|
done
|
2018-05-24 21:20:25 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# replace the fist '-' with ' '
|
|
|
|
travisEnv="$(echo "$travisEnv" | sed '0,/-/{s/-/ /}')"
|
|
|
|
travisEnvAmd64="$(echo "$travisEnvAmd64" | sed '0,/-/{s/-/ /}')"
|
|
|
|
|
|
|
|
# update .travis.yml
|
|
|
|
travisAmd64="$(awk -v 'RS=\n\n' '$1 == "-" && $2 == "stage:" && $3 == "test" && $4 == "images" && $5 == "(amd64)" { $0 = " - stage: test images (amd64)'"$travisEnvAmd64"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
|
|
|
echo "$travisAmd64" > .travis.yml
|
|
|
|
|
|
|
|
travisFull="$(awk -v 'RS=\n\n' '$1 == "-" && $2 == "stage:" && $3 == "test" && $4 == "images" && $5 == "(full)" { $0 = " - stage: test images (full)'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
|
|
|
|
2020-03-08 20:47:56 +01:00
|
|
|
echo "$travisFull" > .travis.yml
|