From 14937970e2c38f98752740ff9b5dfb39f7501fb3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 14 Aug 2024 10:45:44 +0200 Subject: [PATCH] fix: connect compose apps to the right predefined network --- app/Livewire/Project/New/DockerCompose.php | 12 ++++++++++++ app/Models/EnvironmentVariable.php | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/New/DockerCompose.php b/app/Livewire/Project/New/DockerCompose.php index 633ce5bda..5dc085579 100644 --- a/app/Livewire/Project/New/DockerCompose.php +++ b/app/Livewire/Project/New/DockerCompose.php @@ -5,6 +5,8 @@ use App\Models\EnvironmentVariable; use App\Models\Project; use App\Models\Service; +use App\Models\StandaloneDocker; +use App\Models\SwarmDocker; use Illuminate\Support\Str; use Livewire\Component; use Symfony\Component\Yaml\Yaml; @@ -58,11 +60,21 @@ public function submit() $project = Project::where('uuid', $this->parameters['project_uuid'])->first(); $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first(); + $destination_uuid = $this->query['destination']; + $destination = StandaloneDocker::where('uuid', $destination_uuid)->first(); + if (! $destination) { + $destination = SwarmDocker::where('uuid', $destination_uuid)->first(); + } + if (! $destination) { + throw new \Exception('Destination not found. What?!'); + } $service = Service::create([ 'name' => 'service'.Str::random(10), 'docker_compose_raw' => $this->dockerComposeRaw, 'environment_id' => $environment->id, 'server_id' => (int) $server_id, + 'destination_id' => $destination->id, + 'destination_type' => $destination->getMorphClass(), ]); $variables = parseEnvFormatToArray($this->envFile); foreach ($variables as $key => $variable) { diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.php index 3cd8c3140..138775aba 100644 --- a/app/Models/EnvironmentVariable.php +++ b/app/Models/EnvironmentVariable.php @@ -151,7 +151,6 @@ protected function isShared(): Attribute private function get_real_environment_variables(?string $environment_variable = null, $resource = null) { - ray($environment_variable, $resource); if ((is_null($environment_variable) && $environment_variable == '') || is_null($resource)) { return null; }