34
3
mirror of https://github.com/joomla-docker/docker-joomla.git synced 2025-01-10 17:14:41 +00:00

Merge pull request #49 from joomla/reorg

Repo Restructure
This commit is contained in:
Michael Babker 2018-02-13 17:25:22 -08:00 committed by GitHub
commit 34536c8941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 98 additions and 49 deletions

View File

@ -2,18 +2,18 @@ language: bash
services: docker services: docker
env: env:
- VARIANT=apache - VARIANT=php5.6/apache
- VARIANT=apache-php7.0 - VARIANT=php7.0/apache
- VARIANT=apache-php7.1 - VARIANT=php7.1/apache
- VARIANT=apache-php7.2 - VARIANT=php7.2/apache
- VARIANT=fpm - VARIANT=php5.6/fpm
- VARIANT=fpm-alpine - VARIANT=php7.0/fpm
- VARIANT=fpm-php7.0 - VARIANT=php7.1/fpm
- VARIANT=fpm-php7.0-alpine - VARIANT=php7.2/fpm
- VARIANT=fpm-php7.1 - VARIANT=php5.6/fpm-alpine
- VARIANT=fpm-php7.1-alpine - VARIANT=php7.0/fpm-alpine
- VARIANT=fpm-php7.2 - VARIANT=php7.1/fpm-alpine
- VARIANT=fpm-php7.2-alpine - VARIANT=php7.2/fpm-alpine
install: install:
- git clone https://github.com/docker-library/official-images.git ~/official-images - git clone https://github.com/docker-library/official-images.git ~/official-images

View File

@ -1,9 +1,16 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
# Latest available version based on https://downloads.joomla.org/technical-requirements - PHP 7.1 due to known 7.2 bugs still present
defaultPhpVersion='php7.1'
defaultVariant='apache'
self="$(basename "$BASH_SOURCE")" self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
phpVersions=( php*.*/ )
phpVersions=( "${phpVersions[@]%/}" )
# get the most recent commit which modified any of "$@" # get the most recent commit which modified any of "$@"
fileCommit() { fileCommit() {
git log -1 --format='format:%H' HEAD -- "$@" git log -1 --format='format:%H' HEAD -- "$@"
@ -40,35 +47,62 @@ join() {
echo "${out#$sep}" echo "${out#$sep}"
} }
for variant in apache apache-php7.0 apache-php7.1 apache-php7.2 fpm fpm-alpine fpm-php7.0 fpm-php7.0-alpine fpm-php7.1 fpm-php7.1-alpine fpm-php7.2 fpm-php7.2-alpine; do for phpVersion in "${phpVersions[@]}"; do
commit="$(dirCommit "$variant")" for variant in apache fpm fpm-alpine; do
dir="$phpVersion/$variant"
[ -f "$dir/Dockerfile" ] || continue
fullVersion="$(git show "$commit":"$variant/Dockerfile" | awk '$1 == "ENV" && $2 == "JOOMLA_VERSION" { print $3; exit }')" commit="$(dirCommit "$dir")"
fullVersion="$(git show "$commit":"$dir/Dockerfile" | awk '$1 == "ENV" && $2 == "JOOMLA_VERSION" { print $3; exit }')"
if [[ "$fullVersion" != *.*.* && "$fullVersion" == *.* ]]; then if [[ "$fullVersion" != *.*.* && "$fullVersion" == *.* ]]; then
fullVersion+='.0' fullVersion+='.0'
fi fi
versionAliases=() versionAliases=()
while [ "${fullVersion%.*}" != "$fullVersion" ]; do while [ "${fullVersion%[.-]*}" != "$fullVersion" ]; do
versionAliases+=( $fullVersion ) versionAliases+=( $fullVersion )
fullVersion="${fullVersion%.*}" fullVersion="${fullVersion%[.-]*}"
done done
versionAliases+=( versionAliases+=(
$fullVersion $fullVersion
latest latest
) )
phpVersionAliases=( "${versionAliases[@]/%/-$phpVersion}" )
phpVersionAliases=( "${phpVersionAliases[@]//latest-/}" )
variantAliases=( "${versionAliases[@]/%/-$variant}" ) variantAliases=( "${versionAliases[@]/%/-$variant}" )
variantAliases=( "${variantAliases[@]//latest-/}" ) variantAliases=( "${variantAliases[@]//latest-/}" )
if [ "$variant" = 'apache' ]; then phpVersionVariantAliases=( "${versionAliases[@]/%/-$phpVersion-$variant}" )
variantAliases+=( "${versionAliases[@]}" ) phpVersionVariantAliases=( "${phpVersionVariantAliases[@]//latest-/}" )
fullAliases=()
if [ "$phpVersion" = "$defaultPhpVersion" ]; then
fullAliases+=( "${variantAliases[@]}" )
if [ "$variant" = "$defaultVariant" ]; then
fullAliases+=( "${versionAliases[@]}" )
fi fi
fi
fullAliases+=(
"${phpVersionVariantAliases[@]}"
)
if [ "$variant" = "$defaultVariant" ]; then
fullAliases+=( "${phpVersionAliases[@]}" )
fi
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$dir/Dockerfile")"
echo echo
cat <<-EOE cat <<-EOE
Tags: $(join ', ' "${variantAliases[@]}") Tags: $(join ', ' "${fullAliases[@]}")
GitCommit: $commit GitCommit: $commit
Directory: $variant Directory: $dir
EOE EOE
done done
done

View File

@ -73,9 +73,23 @@ if (!isset($signature))
exit(1); exit(1);
} }
foreach (['apache', 'apache-php7.0', 'apache-php7.1', 'apache-php7.2', 'fpm', 'fpm-php7.0', 'fpm-php7.1', 'fpm-php7.2'] as $variant) $phpVersions = [];
$platforms = ['apache', 'fpm', 'fpm-alpine'];
/** @var DirectoryIterator $dir */
foreach (new DirectoryIterator(__DIR__) as $dir)
{ {
$dockerfile = __DIR__ . "/$variant/Dockerfile"; if (substr($dir->getFilename(), 0, 3) === 'php')
{
$phpVersions[] = $dir->getFilename();
}
}
foreach ($phpVersions as $phpVersion)
{
foreach ($platforms as $platform)
{
$dockerfile = __DIR__ . "/$phpVersion/$platform/Dockerfile";
$fileContents = file_get_contents($dockerfile); $fileContents = file_get_contents($dockerfile);
$fileContents = preg_replace('#ENV JOOMLA_VERSION [^ ]*\n#', "ENV JOOMLA_VERSION $version\n", $fileContents); $fileContents = preg_replace('#ENV JOOMLA_VERSION [^ ]*\n#', "ENV JOOMLA_VERSION $version\n", $fileContents);
@ -84,8 +98,9 @@ foreach (['apache', 'apache-php7.0', 'apache-php7.1', 'apache-php7.2', 'fpm', 'f
file_put_contents($dockerfile, $fileContents); file_put_contents($dockerfile, $fileContents);
// To make management easier, we use these files for all variants // To make management easier, we use these files for all variants
copy(__DIR__ . '/docker-entrypoint.sh', __DIR__ . "/$variant/docker-entrypoint.sh"); copy(__DIR__ . '/docker-entrypoint.sh', __DIR__ . "/$phpVersion/$platform/docker-entrypoint.sh");
copy(__DIR__ . '/makedb.php', __DIR__ . "/$variant/makedb.php"); copy(__DIR__ . '/makedb.php', __DIR__ . "/$phpVersion/$platform/makedb.php");
}
} }
echo 'Dockerfile variants updated' . PHP_EOL; echo 'Dockerfile variants updated' . PHP_EOL;