From 8ba049b6c06e0330b6aa1fb7af2746fb4da445e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=BCr=C5=9Fat=20Canci=C4=9Fer?= <54108206+kursatcanciger@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:55:03 +0300 Subject: [PATCH] Fixed undefined array key mariadb10|11 error on installation. (#703) --- .../InteractsWithDockerComposeServices.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Console/Concerns/InteractsWithDockerComposeServices.php b/src/Console/Concerns/InteractsWithDockerComposeServices.php index d8118a71..db290d9f 100644 --- a/src/Console/Concerns/InteractsWithDockerComposeServices.php +++ b/src/Console/Concerns/InteractsWithDockerComposeServices.php @@ -82,12 +82,25 @@ protected function buildDockerCompose(array $services) ->all(); } + // Update the dependencies if the MariaDB service is used... + if (in_array('mariadb10', $services) || in_array('mariadb11', $services)) { + $compose['services']['laravel.test']['depends_on'] = array_map(function ($dependedItem) { + if (in_array($dependedItem, ['mariadb10', 'mariadb11'])) { + return 'mariadb'; + } + + return $dependedItem; + }, $compose['services']['laravel.test']['depends_on']); + } + // Add the services to the docker-compose.yml... collect($services) ->filter(function ($service) use ($compose) { return ! array_key_exists($service, $compose['services'] ?? []); })->each(function ($service) use (&$compose) { - $compose['services'][$service] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")[$service]; + in_array($service, ['mariadb10', 'mariadb11']) + ? $compose['services']['mariadb'] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")['mariadb'] + : $compose['services'][$service] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")[$service]; }); // Merge volumes... @@ -97,6 +110,10 @@ protected function buildDockerCompose(array $services) })->filter(function ($service) use ($compose) { return ! array_key_exists($service, $compose['volumes'] ?? []); })->each(function ($service) use (&$compose) { + if (in_array($service, ['mariadb10', 'mariadb11'])) { + $service = 'mariadb'; + } + $compose['volumes']["sail-{$service}"] = ['driver' => 'local']; });