2023-04-24 23:16:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Action;
|
|
|
|
|
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
|
|
|
|
final class CreateFinalConfigurationData
|
|
|
|
{
|
|
|
|
public function handle(string $configFile, \Closure $next) {
|
|
|
|
$configurationData = array_merge(
|
|
|
|
Yaml::parseFile(filename: __DIR__ . '/../../resources/build.defaults.yaml'),
|
|
|
|
Yaml::parseFile(filename: $configFile),
|
|
|
|
);
|
|
|
|
|
|
|
|
if (isset($configurationData['docker-compose'])) {
|
|
|
|
$configurationData['dockerCompose'] = $configurationData['docker-compose'];
|
|
|
|
$configurationData['docker-compose'] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$configurationData['managedText'] = 'Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.';
|
|
|
|
|
2023-05-08 23:18:46 +00:00
|
|
|
$basePackages = [
|
|
|
|
'git',
|
|
|
|
'libpng-dev',
|
|
|
|
'libzip-dev',
|
|
|
|
// TODO: only add `mariadb-client` if MariaDB is used.
|
|
|
|
'mariadb-client',
|
|
|
|
'unzip',
|
|
|
|
];
|
|
|
|
|
|
|
|
$phpExtensions = [
|
|
|
|
'bcmath',
|
|
|
|
'gd',
|
|
|
|
// TODO: only add `pdo_mysql` if its used.
|
|
|
|
'pdo_mysql',
|
|
|
|
'zip',
|
|
|
|
];
|
|
|
|
|
|
|
|
$configurationData['dockerfile']['stages']['build']['packages'] = $basePackages;
|
|
|
|
$configurationData['dockerfile']['stages']['build']['extensions'] = $phpExtensions;
|
|
|
|
|
2023-04-24 23:16:21 +00:00
|
|
|
return $next($configurationData);
|
|
|
|
}
|
|
|
|
}
|