2015-07-25 18:42:58 +00:00
|
|
|
#!/bin/bash
|
2016-08-16 12:14:03 +00:00
|
|
|
set -eu
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2019-11-29 19:06:00 +00:00
|
|
|
# Latest available version based on https://downloads.joomla.org/technical-requirements
|
|
|
|
defaultPhpVersion='php7.3'
|
2018-02-12 23:51:50 +00:00
|
|
|
defaultVariant='apache'
|
|
|
|
|
2016-08-16 12:14:03 +00:00
|
|
|
self="$(basename "$BASH_SOURCE")"
|
2015-07-25 18:42:58 +00:00
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
2018-02-12 23:51:50 +00:00
|
|
|
phpVersions=( php*.*/ )
|
|
|
|
phpVersions=( "${phpVersions[@]%/}" )
|
|
|
|
|
2016-08-16 12:14:03 +00:00
|
|
|
# get the most recent commit which modified any of "$@"
|
|
|
|
fileCommit() {
|
|
|
|
git log -1 --format='format:%H' HEAD -- "$@"
|
|
|
|
}
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2016-08-16 12:14:03 +00:00
|
|
|
# get the most recent commit which modified "$1/Dockerfile" or any file COPY'd from "$1/Dockerfile"
|
|
|
|
dirCommit() {
|
|
|
|
local dir="$1"; shift
|
|
|
|
(
|
|
|
|
cd "$dir"
|
|
|
|
fileCommit \
|
|
|
|
Dockerfile \
|
|
|
|
$(git show HEAD:./Dockerfile | awk '
|
|
|
|
toupper($1) == "COPY" {
|
|
|
|
for (i = 2; i < NF; i++) {
|
|
|
|
print $i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
')
|
|
|
|
)
|
|
|
|
}
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2018-02-14 01:48:51 +00:00
|
|
|
getArches() {
|
|
|
|
local repo="$1"; shift
|
|
|
|
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
|
|
|
|
|
|
|
|
eval "declare -g -A parentRepoToArches=( $(
|
|
|
|
find -name 'Dockerfile' -exec awk '
|
|
|
|
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
|
|
|
|
print "'"$officialImagesUrl"'" $2
|
|
|
|
}
|
|
|
|
' '{}' + \
|
|
|
|
| sort -u \
|
|
|
|
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
|
|
|
|
) )"
|
|
|
|
}
|
|
|
|
getArches 'joomla'
|
|
|
|
|
2016-08-16 12:14:03 +00:00
|
|
|
cat <<-EOH
|
2020-08-26 19:47:39 +00:00
|
|
|
# this file is generated via https://github.com/joomla-docker/docker-joomla/blob/$(fileCommit "$self")/$self
|
2016-08-16 12:14:03 +00:00
|
|
|
|
2020-09-02 13:22:35 +00:00
|
|
|
Maintainers: Harald Leithner <harald.leithner@community.joomla.org> (@HLeithner)
|
2020-08-26 19:47:39 +00:00
|
|
|
GitRepo: https://github.com/joomla-docker/docker-joomla.git
|
2016-08-16 12:14:03 +00:00
|
|
|
EOH
|
|
|
|
|
|
|
|
# prints "$2$1$3$1...$N"
|
|
|
|
join() {
|
|
|
|
local sep="$1"; shift
|
|
|
|
local out; printf -v out "${sep//%/%%}%s" "$@"
|
|
|
|
echo "${out#$sep}"
|
|
|
|
}
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2018-02-12 23:51:50 +00:00
|
|
|
for phpVersion in "${phpVersions[@]}"; do
|
2018-02-14 01:11:57 +00:00
|
|
|
for variant in apache fpm fpm-alpine; do
|
2018-02-12 23:51:50 +00:00
|
|
|
dir="$phpVersion/$variant"
|
|
|
|
[ -f "$dir/Dockerfile" ] || continue
|
2016-08-16 12:14:03 +00:00
|
|
|
|
2018-02-12 23:51:50 +00:00
|
|
|
commit="$(dirCommit "$dir")"
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2018-02-12 23:51:50 +00:00
|
|
|
fullVersion="$(git show "$commit":"$dir/Dockerfile" | awk '$1 == "ENV" && $2 == "JOOMLA_VERSION" { print $3; exit }')"
|
|
|
|
if [[ "$fullVersion" != *.*.* && "$fullVersion" == *.* ]]; then
|
|
|
|
fullVersion+='.0'
|
|
|
|
fi
|
|
|
|
|
|
|
|
versionAliases=()
|
|
|
|
while [ "${fullVersion%[.-]*}" != "$fullVersion" ]; do
|
|
|
|
versionAliases+=( $fullVersion )
|
|
|
|
fullVersion="${fullVersion%[.-]*}"
|
|
|
|
done
|
|
|
|
versionAliases+=(
|
|
|
|
$fullVersion
|
|
|
|
latest
|
|
|
|
)
|
|
|
|
|
|
|
|
phpVersionAliases=( "${versionAliases[@]/%/-$phpVersion}" )
|
|
|
|
phpVersionAliases=( "${phpVersionAliases[@]//latest-/}" )
|
|
|
|
|
|
|
|
variantAliases=( "${versionAliases[@]/%/-$variant}" )
|
|
|
|
variantAliases=( "${variantAliases[@]//latest-/}" )
|
2016-08-16 12:14:03 +00:00
|
|
|
|
2018-02-12 23:51:50 +00:00
|
|
|
phpVersionVariantAliases=( "${versionAliases[@]/%/-$phpVersion-$variant}" )
|
|
|
|
phpVersionVariantAliases=( "${phpVersionVariantAliases[@]//latest-/}" )
|
2016-08-16 12:14:03 +00:00
|
|
|
|
2018-02-12 23:51:50 +00:00
|
|
|
fullAliases=()
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2018-02-12 23:51:50 +00:00
|
|
|
if [ "$phpVersion" = "$defaultPhpVersion" ]; then
|
|
|
|
fullAliases+=( "${variantAliases[@]}" )
|
|
|
|
|
|
|
|
if [ "$variant" = "$defaultVariant" ]; then
|
|
|
|
fullAliases+=( "${versionAliases[@]}" )
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
fullAliases+=(
|
|
|
|
"${phpVersionVariantAliases[@]}"
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ "$variant" = "$defaultVariant" ]; then
|
|
|
|
fullAliases+=( "${phpVersionAliases[@]}" )
|
|
|
|
fi
|
|
|
|
|
|
|
|
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$dir/Dockerfile")"
|
2018-02-14 01:48:51 +00:00
|
|
|
variantArches="${parentRepoToArches[$variantParent]}"
|
2018-02-12 23:51:50 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
cat <<-EOE
|
|
|
|
Tags: $(join ', ' "${fullAliases[@]}")
|
2018-02-14 01:48:51 +00:00
|
|
|
Architectures: $(join ', ' $variantArches)
|
2018-02-12 23:51:50 +00:00
|
|
|
GitCommit: $commit
|
|
|
|
Directory: $dir
|
|
|
|
EOE
|
|
|
|
done
|
2015-07-25 18:42:58 +00:00
|
|
|
done
|