From 1defed27a02a5b50c7afb176b9714bad1a5337be Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 11 Mar 2024 15:19:04 +0100 Subject: [PATCH] Refactor compose file generation and add link to documentation --- app/Jobs/ApplicationDeploymentJob.php | 24 ++++++++++++++++++- .../views/livewire/server/proxy.blade.php | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 0dedfd596..b9c60605f 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1077,7 +1077,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private function generate_compose_file() { $ports = $this->application->settings->is_static ? [80] : $this->application->ports_exposes_array; - + $onlyPort = null; + if (count($ports) > 0) { + $onlyPort = $ports[0]; + } $persistent_storages = $this->generate_local_persistent_volumes(); $volume_names = $this->generate_local_persistent_volumes_only_volume_names(); $environment_variables = $this->generate_environment_variables($ports); @@ -1088,6 +1091,25 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $labels = $labels->filter(function ($value, $key) { return !Str::startsWith($value, 'coolify.'); }); + $found_caddy_labels = $labels->filter(function ($value, $key) { + return Str::startsWith($value, 'caddy_'); + }); + if ($found_caddy_labels->count() === 0) { + if ($this->pull_request_id !== 0) { + $domains = str(data_get($this->preview, 'fqdn'))->explode(','); + } else { + $domains = str(data_get($this->application, 'fqdn'))->explode(','); + } + $labels = $labels->merge(fqdnLabelsForCaddy( + network: $this->application->destination->network, + uuid: $this->application->uuid, + domains: $domains, + onlyPort: $onlyPort, + is_force_https_enabled: $this->application->isForceHttpsEnabled(), + is_gzip_enabled: $this->application->isGzipEnabled(), + is_stripprefix_enabled: $this->application->isStripprefixEnabled() + )); + } $this->application->custom_labels = base64_encode($labels->implode("\n")); $this->application->save(); } else { diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php index 7c6599792..ba3909739 100644 --- a/resources/views/livewire/server/proxy.blade.php +++ b/resources/views/livewire/server/proxy.blade.php @@ -13,7 +13,7 @@ Save -
Before switching proxies, please read this.
+
Before switching proxies, please read this.
@if ($server->proxyType() === 'TRAEFIK_V2')
Traefik v2
@elseif ($server->proxyType() === 'CADDY')