diff --git a/app/Models/Server.php b/app/Models/Server.php index 5aa571452..650e5129a 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -228,6 +228,23 @@ class Server extends BaseModel return $standaloneDocker->applications; })->flatten(); } + public function dockerComposeBasedApplications() + { + return $this->applications()->filter(function ($application) { + return data_get($application, 'build_pack') === 'dockercompose'; + }); + } + public function dockerComposeBasedPreviewDeployments() + { + return $this->previews()->filter(function ($preview) { + $applicationId = data_get($preview, 'application_id'); + $application = Application::find($applicationId); + if (!$application) { + return false; + } + return data_get($application, 'build_pack') === 'dockercompose'; + }); + } public function services() { return $this->hasMany(Service::class); diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php index 86946231b..2f595d1c6 100644 --- a/bootstrap/helpers/proxy.php +++ b/bootstrap/helpers/proxy.php @@ -1,6 +1,7 @@ standaloneDockers)->map(function ($docker) { return $docker['network']; }); // Service networks - foreach($server->services()->get() as $service) { + foreach ($server->services()->get() as $service) { $networks->push($service->networks()); } + // Docker compose based apps + $docker_compose_apps = $server->dockerComposeBasedApplications(); + foreach ($docker_compose_apps as $app) { + $networks->push($app->uuid); + } + // Docker compose based preview deployments + $docker_compose_previews = $server->dockerComposeBasedPreviewDeployments(); + foreach ($docker_compose_previews as $preview) { + $pullRequestId = $preview->pull_request_id; + $applicationId = $preview->application_id; + $application = Application::find($applicationId); + if (!$application) { + continue; + } + $network = "{$application->uuid}-{$pullRequestId}"; + $networks->push($network); + } $networks = collect($networks)->flatten()->unique(); if ($networks->count() === 0) { $networks = collect(['coolify']); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 324bd0652..8eb1fd443 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1072,7 +1072,6 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal throw new \Exception($e->getMessage()); } } - ray($yaml); $server = $resource->destination->server; $topLevelVolumes = collect(data_get($yaml, 'volumes', [])); if ($pull_request_id !== 0) {