From 7d54535f6abac97f5070be17c536803b5c0cccda Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Mon, 12 Feb 2018 17:38:02 -0600 Subject: [PATCH] Update update script to use new variant structure --- update.php | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/update.php b/update.php index e45094e..981c7bc 100644 --- a/update.php +++ b/update.php @@ -73,19 +73,34 @@ if (!isset($signature)) 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']; + +/** @var DirectoryIterator $dir */ +foreach (new DirectoryIterator(__DIR__) as $dir) { - $dockerfile = __DIR__ . "/$variant/Dockerfile"; + if (substr($dir->getFilename(), 0, 3) === 'php') + { + $phpVersions[] = $dir->getFilename(); + } +} - $fileContents = file_get_contents($dockerfile); - $fileContents = preg_replace('#ENV JOOMLA_VERSION [^ ]*\n#', "ENV JOOMLA_VERSION $version\n", $fileContents); - $fileContents = preg_replace('#ENV JOOMLA_SHA1 [^ ]*\n#', "ENV JOOMLA_SHA1 $signature\n\n", $fileContents); +foreach ($phpVersions as $phpVersion) +{ + foreach ($platforms as $platform) + { + $dockerfile = __DIR__ . "/$phpVersion/$platform/Dockerfile"; - file_put_contents($dockerfile, $fileContents); + $fileContents = file_get_contents($dockerfile); + $fileContents = preg_replace('#ENV JOOMLA_VERSION [^ ]*\n#', "ENV JOOMLA_VERSION $version\n", $fileContents); + $fileContents = preg_replace('#ENV JOOMLA_SHA1 [^ ]*\n#', "ENV JOOMLA_SHA1 $signature\n\n", $fileContents); - // To make management easier, we use these files for all variants - copy(__DIR__ . '/docker-entrypoint.sh', __DIR__ . "/$variant/docker-entrypoint.sh"); - copy(__DIR__ . '/makedb.php', __DIR__ . "/$variant/makedb.php"); + file_put_contents($dockerfile, $fileContents); + + // To make management easier, we use these files for all variants + copy(__DIR__ . '/docker-entrypoint.sh', __DIR__ . "/$phpVersion/$platform/docker-entrypoint.sh"); + copy(__DIR__ . '/makedb.php', __DIR__ . "/$phpVersion/$platform/makedb.php"); + } } echo 'Dockerfile variants updated' . PHP_EOL;