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=(
|
2021-09-08 23:07:39 +02:00
|
|
|
['stable-debian']='\nRUN set -ex; \\\n fetchDeps=" \\\n gnupg \\\n "; \\\n apt-get update; \\\n apt-get install -y --no-install-recommends $fetchDeps; \\\n \\\n export GNUPGHOME="$(mktemp -d)"; \\\n gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 08656443618E6567A39524083EE197EF3F9E4287; \\\n \\\n curl -fsSL -o friendica-full-${FRIENDICA_VERSION}.tar.gz \\\n "https://files.friendi.ca/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \\\n curl -fsSL -o friendica-full-${FRIENDICA_VERSION}.tar.gz.asc \\\n "https://files.friendi.ca/friendica-full-${FRIENDICA_VERSION}.tar.gz.asc"; \\\n gpg --batch --verify friendica-full-${FRIENDICA_VERSION}.tar.gz.asc friendica-full-${FRIENDICA_VERSION}.tar.gz; \\\n echo "${FRIENDICA_DOWNLOAD_SHA256} *friendica-full-${FRIENDICA_VERSION}.tar.gz" \| sha256sum -c; \\\n tar -xzf friendica-full-${FRIENDICA_VERSION}.tar.gz -C /usr/src/; \\\n rm friendica-full-${FRIENDICA_VERSION}.tar.gz friendica-full-${FRIENDICA_VERSION}.tar.gz.asc; \\\n mv -f /usr/src/friendica-full-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n \\\n curl -fsSL -o friendica-addons-${FRIENDICA_ADDONS}.tar.gz \\\n "https://files.friendi.ca/friendica-addons-${FRIENDICA_ADDONS}.tar.gz"; \\\n curl -fsSL -o friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc \\\n "https://files.friendi.ca/friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc"; \\\n gpg --batch --verify friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc friendica-addons-${FRIENDICA_ADDONS}.tar.gz; \\\n echo "${FRIENDICA_DOWNLOAD_ADDONS_SHA256} *friendica-addons-${FRIENDICA_ADDONS}.tar.gz" \| sha256sum -c; \\\n mkdir -p /usr/src/friendica/proxy; \\\n mkdir -p /usr/src/friendica/addon; \\\n tar -xzf friendica-addons-${FRIENDICA_ADDONS}.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica-addons-${FRIENDICA_ADDONS}.tar.gz friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc; \\\n \\\n gpgconf --kill all; \\\n rm -rf "$GNUPGHOME"; \\\n \\\n apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \\\n rm -rf /var/lib/apt/lists/*\n'
|
|
|
|
['stable-alpine']='\nRUN set -ex; \\\n apk add --no-cache --virtual .fetch-deps \\\n gnupg \\\n ; \\\n \\\n export GNUPGHOME="$(mktemp -d)"; \\\n gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 08656443618E6567A39524083EE197EF3F9E4287; \\\n \\\n curl -fsSL -o friendica-full-${FRIENDICA_VERSION}.tar.gz \\\n "https://files.friendi.ca/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \\\n curl -fsSL -o friendica-full-${FRIENDICA_VERSION}.tar.gz.asc \\\n "https://files.friendi.ca/friendica-full-${FRIENDICA_VERSION}.tar.gz.asc"; \\\n gpg --batch --verify friendica-full-${FRIENDICA_VERSION}.tar.gz.asc friendica-full-${FRIENDICA_VERSION}.tar.gz; \\\n echo "${FRIENDICA_DOWNLOAD_SHA256} *friendica-full-${FRIENDICA_VERSION}.tar.gz" \| sha256sum -c; \\\n tar -xzf friendica-full-${FRIENDICA_VERSION}.tar.gz -C /usr/src/; \\\n rm friendica-full-${FRIENDICA_VERSION}.tar.gz friendica-full-${FRIENDICA_VERSION}.tar.gz.asc; \\\n mv -f /usr/src/friendica-full-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n \\\n curl -fsSL -o friendica-addons-${FRIENDICA_ADDONS}.tar.gz \\\n "https://files.friendi.ca/friendica-addons-${FRIENDICA_ADDONS}.tar.gz"; \\\n curl -fsSL -o friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc \\\n "https://files.friendi.ca/friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc"; \\\n gpg --batch --verify friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc friendica-addons-${FRIENDICA_ADDONS}.tar.gz; \\\n echo "${FRIENDICA_DOWNLOAD_ADDONS_SHA256} *friendica-addons-${FRIENDICA_ADDONS}.tar.gz" \| sha256sum -c; \\\n mkdir -p /usr/src/friendica/proxy; \\\n mkdir -p /usr/src/friendica/addon; \\\n tar -xzf friendica-addons-${FRIENDICA_ADDONS}.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica-addons-${FRIENDICA_ADDONS}.tar.gz friendica-addons-${FRIENDICA_ADDONS}.tar.gz.asc; \\\n \\\n gpgconf --kill all; \\\n rm -rf "$GNUPGHOME"; \\\n \\\n apk del .fetch-deps\n'
|
2021-09-11 20:26:16 +02:00
|
|
|
['develop-debian']='RUN set -ex; \\\n fetchDeps=" \\\n gnupg \\\n "; \\\n apt-get update; \\\n apt-get install -y --no-install-recommends $fetchDeps;\n'
|
|
|
|
['develop-alpine']='RUN set -ex; \\\n apk add --no-cache --virtual .fetch-deps \\\n gnupg \\\n ;\n'
|
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
|
|
|
)
|
|
|
|
|
2021-08-28 20:55:41 +02:00
|
|
|
min_version='2021.04'
|
2020-09-04 21:31:44 +02:00
|
|
|
|
|
|
|
# version_greater_or_equal A B returns whether A >= B
|
|
|
|
function version_greater_or_equal() {
|
|
|
|
[[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" || "$1" == "$2" ]];
|
|
|
|
}
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-09-10 19:57:15 +02:00
|
|
|
function is_hotfix() {
|
|
|
|
[[ "$1" =~ ^.*-[[:digit:]]+$ ]]
|
2020-09-08 21:40:43 +02:00
|
|
|
}
|
|
|
|
|
2021-09-08 19:57:35 +02:00
|
|
|
function get_sha256_string() {
|
|
|
|
install_type="$1"
|
|
|
|
version="${2,,}"
|
|
|
|
if [[ $install_type == "develop" ]]; then
|
|
|
|
echo ""
|
|
|
|
else
|
|
|
|
echo "ENV FRIENDICA_DOWNLOAD_SHA256 \"$(curl -fsSL https://files.friendi.ca/friendica-full-${version}.tar.gz.sum256 | cut -d' ' -f1)\"\nENV FRIENDICA_DOWNLOAD_ADDONS_SHA256 \"$(curl -fsSL https://files.friendi.ca/friendica-addons-${version}.tar.gz.sum256 | cut -d' ' -f1)\""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-05-24 21:20:25 +02:00
|
|
|
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;
|
2020-09-10 19:57:15 +02:00
|
|
|
s/%%VERSION%%/'"${2:-${1}}"'/g;
|
2020-06-15 00:30:25 +02:00
|
|
|
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
|
|
|
s|%%VARIANT_EXTRAS%%|'"${extras[$variant]}"'|g;
|
2021-09-08 19:57:35 +02:00
|
|
|
s|%%DOWNLOAD_SHA256%%|'"$(get_sha256_string $install_type ${2:-${1}})"'|g;
|
2021-09-08 22:56:55 +02:00
|
|
|
s|%%INSTALL_EXTRAS%%|'"${install_extras[$install_type-${base[$variant]}]}"'|g;
|
2020-06-15 00:30:25 +02:00
|
|
|
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"
|
|
|
|
|
2020-07-23 23:05:23 +02:00
|
|
|
for name in entrypoint cron setup_msmtp; do
|
2020-06-15 00:30:25 +02:00
|
|
|
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"
|
2018-05-24 21:20:25 +02:00
|
|
|
}
|
|
|
|
|
2020-09-10 19:57:15 +02:00
|
|
|
# latest, stable version (just save the major version, not every hotfix)
|
2020-09-04 21:31:44 +02:00
|
|
|
curl -fsSL 'https://files.friendi.ca/' |tac|tac| \
|
2020-09-10 19:57:15 +02:00
|
|
|
grep -oE 'friendica-full-[[:digit:]]+\.[[:digit:]]+(\-[[:digit:]]+){0,1}\.tar\.gz' | \
|
|
|
|
grep -oE '[[:digit:]]+\.[[:digit:]]+' | \
|
2020-09-04 21:31:44 +02:00
|
|
|
sort -uV | \
|
|
|
|
tail -1 > latest.txt
|
|
|
|
|
|
|
|
curl -fsSl 'https://raw.githubusercontent.com/friendica/friendica/develop/VERSION' > develop.txt
|
|
|
|
|
2020-09-08 21:40:43 +02:00
|
|
|
find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\(\.\|\-\)[[:digit:]]\+\(-rc\|-dev\|\-[[:digit:]]\)\?' -exec rm -r '{}' \;
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-09-04 21:31:44 +02:00
|
|
|
fullversions=( $( curl -fsSL 'https://files.friendi.ca/' |tac|tac| \
|
2020-09-10 19:57:15 +02:00
|
|
|
grep -oE 'friendica-full-[[:digit:]]+\.[[:digit:]]+(\-[[:digit:]]+){0,1}\.tar\.gz' | \
|
2020-09-08 21:40:43 +02:00
|
|
|
grep -oE '[[:digit:]]+\.[[:digit:]]+(\-[[:digit:]]+){0,1}' | \
|
2020-09-04 21:31:44 +02:00
|
|
|
sort -urV ) )
|
2020-09-08 21:40:43 +02:00
|
|
|
for version in "${fullversions[@]}"; do
|
2020-09-10 19:57:15 +02:00
|
|
|
# hotfixes are just for Version ENV in the Dockerfile
|
|
|
|
if is_hotfix "$version"; then
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
|
|
|
|
fullversion="$( printf '%s\n' "${fullversions[@]}" | grep -E "^$version" | sort -urV | head -1 )"
|
2018-05-24 21:20:25 +02:00
|
|
|
|
2020-09-08 21:40:43 +02:00
|
|
|
if version_greater_or_equal "$fullversion" "$min_version"; then
|
2020-09-04 21:31:44 +02:00
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
|
2020-09-08 21:40:43 +02:00
|
|
|
create_variant "$version" "$fullversion"
|
2020-09-04 21:31:44 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-09-04 22:28:26 +02:00
|
|
|
githubversions_rc=( $( git ls-remote --heads -q 'https://github.com/friendica/friendica' | \
|
|
|
|
grep -oE '[[:digit:]]+\.[[:digit:]]+\-rc' || true | \
|
2020-09-04 21:31:44 +02:00
|
|
|
sort -urV ) )
|
|
|
|
versions_rc=( $( printf '%s\n' "${githubversions_rc[@]}" | cut -d. -f1-2 | sort -urV ) )
|
|
|
|
for version in "${versions_rc[@]}"; do
|
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
|
|
|
|
create_variant "$version"
|
|
|
|
done
|
|
|
|
fi
|
2018-05-24 21:20:25 +02:00
|
|
|
done
|
2020-09-04 22:28:26 +02:00
|
|
|
|
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
create_variant "$(cat develop.txt)"
|
|
|
|
done
|