From 24f923e88e930dbb701156123e9be2cf105cc4fa Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 14 May 2024 12:19:33 +0200 Subject: [PATCH 1/2] fix: docker compose dependencies for pr previews --- bootstrap/helpers/shared.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index b93b0ec3dc..e34a58e065 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1665,6 +1665,9 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal }); if ($pull_request_id !== 0) { $services->each(function ($service, $serviceName) use ($pull_request_id, $services) { + $service->depends_on = $service->depends_on->map(function ($dependency) use ($pull_request_id) { + return $dependency . "-pr-$pull_request_id"; + }); $services[$serviceName . "-pr-$pull_request_id"] = $service; data_forget($services, $serviceName); }); From 5321a75272962652092c7c05abcb3ae89ec32e8b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 14 May 2024 13:33:29 +0200 Subject: [PATCH 2/2] fix: properly populating dependencies --- bootstrap/helpers/shared.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index e34a58e065..eebaa4bce0 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1259,6 +1259,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $servicePorts = collect(data_get($service, 'ports', [])); $serviceNetworks = collect(data_get($service, 'networks', [])); $serviceVariables = collect(data_get($service, 'environment', [])); + $serviceDependencies = collect(data_get($service, 'depends_on', [])); $serviceLabels = collect(data_get($service, 'labels', [])); $serviceBuildVariables = collect(data_get($service, 'build.args', [])); $serviceVariables = $serviceVariables->merge($serviceBuildVariables); @@ -1370,6 +1371,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal data_set($service, 'volumes', $serviceVolumes->toArray()); } + if ($pull_request_id !== 0 && count($serviceDependencies) > 0) { + $serviceDependencies = $serviceDependencies->map(function ($dependency) use ($pull_request_id) { + return $dependency . "-pr-$pull_request_id"; + }); + data_set($service, 'depends_on', $serviceDependencies->toArray()); + } + // Decide if the service is a database $isDatabase = isDatabaseImage(data_get_str($service, 'image')); data_set($service, 'is_database', $isDatabase); @@ -1665,9 +1673,6 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal }); if ($pull_request_id !== 0) { $services->each(function ($service, $serviceName) use ($pull_request_id, $services) { - $service->depends_on = $service->depends_on->map(function ($dependency) use ($pull_request_id) { - return $dependency . "-pr-$pull_request_id"; - }); $services[$serviceName . "-pr-$pull_request_id"] = $service; data_forget($services, $serviceName); });