From 0653eb8511b17a59d54ce8709113b16b6a641d80 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 2 Jan 2024 16:44:41 +0100 Subject: [PATCH 1/5] set custom labels on every app --- app/Livewire/Project/Application/General.php | 6 ++++++ config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 6b2f07dc3..58dbed11e 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -116,6 +116,9 @@ class General extends Component } $this->isConfigurationChanged = $this->application->isConfigurationChanged(); $this->customLabels = $this->application->parseContainerLabels(); + if (!$this->customLabels) { + $this->resetDefaultLabels(false); + } $this->initialDockerComposeLocation = $this->application->docker_compose_location; $this->checkLabelUpdates(); } @@ -209,6 +212,9 @@ class General extends Component if ($this->ports_exposes !== $this->application->ports_exposes) { $this->resetDefaultLabels(false); } + if (!$this->customLabels) { + $this->resetDefaultLabels(false); + } if (data_get($this->application, 'build_pack') === 'dockerimage') { $this->validate([ 'application.docker_registry_image_name' => 'required', diff --git a/config/sentry.php b/config/sentry.php index 84bd36a64..9296ac156 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.177', + 'release' => '4.0.0-beta.178', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 2fa0950f8..661773b8d 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Tue, 2 Jan 2024 16:46:08 +0100 Subject: [PATCH 2/5] add compose link --- resources/views/livewire/project/application/general.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 98fc648ee..09592effb 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -50,7 +50,7 @@ @if ($application->build_pack === 'dockercompose') + helper="WARNING: Advanced use cases only. Your docker compose file will be deployed as-is. Nothing is modified by Coolify. You need to configure the proxy parts. More info in the documentation." /> @if (count($parsedServices) > 0 && !$application->settings->is_raw_compose_deployment_enabled) @foreach (data_get($parsedServices, 'services') as $serviceName => $service) @if (!isDatabaseImage(data_get($service, 'image'))) From a8ca57d095a501b60f271fdcffb558dcfdd94d19 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 2 Jan 2024 16:47:05 +0100 Subject: [PATCH 3/5] Update link in helper message in general.blade.php --- resources/views/livewire/project/application/general.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 09592effb..8d38aa189 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -50,7 +50,7 @@ @if ($application->build_pack === 'dockercompose') + helper="WARNING: Advanced use cases only. Your docker compose file will be deployed as-is. Nothing is modified by Coolify. You need to configure the proxy parts. More info in the documentation." /> @if (count($parsedServices) > 0 && !$application->settings->is_raw_compose_deployment_enabled) @foreach (data_get($parsedServices, 'services') as $serviceName => $service) @if (!isDatabaseImage(data_get($service, 'image'))) From 83d96c8d114c51b63637d0dbac2a0c50354b7a2d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 2 Jan 2024 17:14:52 +0100 Subject: [PATCH 4/5] Refactor custom labels handling in General.php and update Docker Compose Content label in general.blade.php --- app/Livewire/Project/Application/General.php | 15 ++++++++++----- .../project/application/general.blade.php | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 58dbed11e..798794e49 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -117,7 +117,9 @@ class General extends Component $this->isConfigurationChanged = $this->application->isConfigurationChanged(); $this->customLabels = $this->application->parseContainerLabels(); if (!$this->customLabels) { - $this->resetDefaultLabels(false); + $this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n"); + $this->application->custom_labels = base64_encode($this->customLabels); + $this->application->save(); } $this->initialDockerComposeLocation = $this->application->docker_compose_location; $this->checkLabelUpdates(); @@ -204,7 +206,12 @@ class General extends Component public function submit($showToaster = true) { try { - ray($this->initialDockerComposeLocation, $this->application->docker_compose_location); + if (!$this->customLabels) { + $this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n"); + $this->application->custom_labels = base64_encode($this->customLabels); + $this->application->save(); + } + if ($this->application->build_pack === 'dockercompose' && $this->initialDockerComposeLocation !== $this->application->docker_compose_location) { $this->loadComposeFile(); } @@ -212,9 +219,7 @@ class General extends Component if ($this->ports_exposes !== $this->application->ports_exposes) { $this->resetDefaultLabels(false); } - if (!$this->customLabels) { - $this->resetDefaultLabels(false); - } + if (data_get($this->application, 'build_pack') === 'dockerimage') { $this->validate([ 'application.docker_registry_image_name' => 'required', diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 8d38aa189..3f6d3984f 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -189,7 +189,7 @@ Reload Compose File @if ($application->settings->is_raw_compose_deployment_enabled) + label="Docker Compose Content (applicationId: {{$application->id}})" helper="You need to modify the docker compose file." /> @else From cb80341a78308d2c4a36b538294bd0c128d19240 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 2 Jan 2024 17:22:44 +0100 Subject: [PATCH 5/5] Fix customLabels assignment when proxyType is TRAEFIK_V2 --- app/Livewire/Project/Application/General.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 798794e49..f54a46e09 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -116,7 +116,7 @@ class General extends Component } $this->isConfigurationChanged = $this->application->isConfigurationChanged(); $this->customLabels = $this->application->parseContainerLabels(); - if (!$this->customLabels) { + if (!$this->customLabels && $this->application->destination->server->proxyType() === 'TRAEFIK_V2') { $this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n"); $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save(); @@ -206,7 +206,7 @@ class General extends Component public function submit($showToaster = true) { try { - if (!$this->customLabels) { + if (!$this->customLabels && $this->application->destination->server->proxyType() === 'TRAEFIK_V2') { $this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n"); $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save();