mirror of
https://github.com/nextcloud/docker.git
synced 2025-04-25 12:50:54 +02:00
*: rework update and generation scripts
This is necessary in order to have proper generation of variant and version-based Dockerfiles from a single template. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
parent
ff52578e4f
commit
c34d30fb49
2 changed files with 108 additions and 22 deletions
47
update.sh
47
update.sh
|
@ -1,17 +1,38 @@
|
|||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
current="$(
|
||||
git ls-remote --tags https://github.com/nextcloud/server.git \
|
||||
| awk -F 'refs/tags/' '
|
||||
$2 ~ /^v?[0-9]/ {
|
||||
gsub(/^v|\^.*/, "", $2);
|
||||
print $2;
|
||||
}
|
||||
' \
|
||||
| sort -uV \
|
||||
| tail -1
|
||||
)"
|
||||
declare -A cmd=(
|
||||
[apache]='apache2-foreground'
|
||||
[fpm]='php-fpm'
|
||||
)
|
||||
|
||||
set -x
|
||||
sed -ri 's/^(ENV NEXTCLOUD_VERSION) .*/\1 '"$current"'/;' ./Dockerfile
|
||||
latests=( $(curl -sSL 'https://nextcloud.com/changelog/' |tac|tac| \
|
||||
grep -o "\(Version\|Release\)\s\+[[:digit:]]\+\(\.[[:digit:]]\+\)\+" | \
|
||||
awk '{ print $2 }' | sort -V ) )
|
||||
|
||||
for latest in "${latests[@]}"; do
|
||||
version=$(echo "$latest" | cut -d. -f1-2)
|
||||
|
||||
for variant in apache fpm; do
|
||||
# Create the version+variant directory with a Dockerfile.
|
||||
mkdir -p "$version/$variant"
|
||||
cp Dockerfile.template "$version/$variant/Dockerfile"
|
||||
|
||||
echo "updating $latest [$version] $variant"
|
||||
|
||||
# Replace the variables.
|
||||
sed -ri -e '
|
||||
s/%%VARIANT%%/'"$variant"'/g;
|
||||
s/%%VERSION%%/'"$latest"'/g;
|
||||
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
||||
' "$version/$variant/Dockerfile"
|
||||
|
||||
# Remove Apache commands if we're not an Apache variant.
|
||||
if [ "$variant" != "apache" ]; then
|
||||
sed -ri -e '/a2enmod/d' "$version/$variant/Dockerfile"
|
||||
fi
|
||||
|
||||
# Copy the docker-entrypoint.
|
||||
cp docker-entrypoint.sh "$version/$variant/docker-entrypoint.sh"
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue