From ba74d55b4cb0fb1b15ec78e54bcc289fce8934c1 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 12:10:36 +0200 Subject: [PATCH 01/12] fix: report livewire errors --- bootstrap/helpers/shared.php | 6 ++++-- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index cb1a758a9..e94534fed 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -100,7 +100,8 @@ function handleError(?Throwable $error = null, ?Livewire\Component $livewire = n return "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds."; } if (isset($livewire)) { - return $livewire->emit('error', $message); + $livewire->emit('error', $message); + throw new RuntimeException($message); } throw new RuntimeException($message); @@ -240,7 +241,8 @@ function base_ip(): string } return "localhost"; } -function getOnlyFqdn(String $fqdn) { +function getOnlyFqdn(String $fqdn) +{ $url = Url::fromString($fqdn); $host = $url->getHost(); $scheme = $url->getScheme(); diff --git a/config/sentry.php b/config/sentry.php index 39c920a43..3a1955646 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.44', + 'release' => '4.0.0-beta.45', // 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 34ed5e7bd..462d9f013 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Sun, 24 Sep 2023 14:12:07 +0400 Subject: [PATCH 02/12] ui: Fixed z-index for version link. --- resources/views/components/version.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/components/version.blade.php b/resources/views/components/version.blade.php index 28d5f6206..3ed4586da 100644 --- a/resources/views/components/version.blade.php +++ b/resources/views/components/version.blade.php @@ -1,2 +1,2 @@ -merge(['class' => 'text-xs cursor-pointer opacity-20 hover:opacity-100 hover:text-white']) }} +merge(['class' => 'text-xs cursor-pointer opacity-20 hover:opacity-100 hover:text-white z-50']) }} href="https://github.com/coollabsio/coolify/releases/tag/v{{ config('version') }}">v{{ config('version') }} From e9149e534de2d84868454190ffdc3cc1d99c2ff6 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 17:31:41 +0200 Subject: [PATCH 03/12] temporary disable containerstatusjob failed --- app/Jobs/ContainerStatusJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 1067d0028..68f4269a6 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -258,7 +258,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted $this->server->team->notify(new ContainerStopped($containerName, $this->server, $url)); } } catch (\Throwable $e) { - send_internal_notification('ContainerStatusJob failed with: ' . $e->getMessage()); + // send_internal_notification('ContainerStatusJob failed with: ' . $e->getMessage()); ray($e->getMessage()); throw $e; } From e74899611b5fc99a9ee6f18b97ec7a1372b73a30 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 17:39:12 +0200 Subject: [PATCH 04/12] fix: links with path --- app/Jobs/ApplicationDeploymentJob.php | 2 +- app/Models/Service.php | 4 ++-- app/View/Components/Services/Links.php | 2 +- bootstrap/helpers/shared.php | 5 +++-- resources/views/components/applications/links.blade.php | 6 +++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index d6c4b5ccf..ee2f01b74 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -97,7 +97,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted if ($this->pull_request_id !== 0) { $this->preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id); if ($this->application->fqdn) { - $preview_fqdn = getOnlyFqdn(data_get($this->preview, 'fqdn')); + $preview_fqdn = getFqdnWithoutPort(data_get($this->preview, 'fqdn')); $template = $this->application->preview_url_template; $url = Url::fromString($this->application->fqdn); $host = $url->getHost(); diff --git a/app/Models/Service.php b/app/Models/Service.php index 4b66fdf19..ae590f13f 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -377,7 +377,7 @@ class Service extends BaseModel } else { $number = 0; } - $fqdn = getOnlyFqdn(data_get($fqdns, $number, $fqdns->first())); + $fqdn = getFqdnWithoutPort(data_get($fqdns, $number, $fqdns->first())); $environments = collect(data_get($service, 'environment')); $environments = $environments->map(function ($envValue) use ($value, $fqdn) { $envValue = Str::of($envValue)->replace($value, $fqdn); @@ -393,7 +393,7 @@ class Service extends BaseModel } else { $number = 0; } - $fqdn = getOnlyFqdn(data_get($fqdns, $number, $fqdns->first())); + $fqdn = getFqdnWithoutPort(data_get($fqdns, $number, $fqdns->first())); $url = Url::fromString($fqdn)->getHost(); $environments = collect(data_get($service, 'environment')); $environments = $environments->map(function ($envValue) use ($value, $url) { diff --git a/app/View/Components/Services/Links.php b/app/View/Components/Services/Links.php index 69fefa7a2..b2cc8618d 100644 --- a/app/View/Components/Services/Links.php +++ b/app/View/Components/Services/Links.php @@ -19,7 +19,7 @@ class Links extends Component if ($application->fqdn) { $fqdns = collect(Str::of($application->fqdn)->explode(',')); $fqdns->map(function ($fqdn) { - $this->links->push(getOnlyFqdn($fqdn)); + $this->links->push(getFqdnWithoutPort($fqdn)); }); } if ($application->ports) { diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index e94534fed..63f7fb8b1 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -241,12 +241,13 @@ function base_ip(): string } return "localhost"; } -function getOnlyFqdn(String $fqdn) +function getFqdnWithoutPort(String $fqdn) { $url = Url::fromString($fqdn); $host = $url->getHost(); $scheme = $url->getScheme(); - return "$scheme://$host"; + $path = $url->getPath(); + return "$scheme://$host$path"; } /** * If fqdn is set, return it, otherwise return public ip. diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.php index c38ea185f..c9f9b0de6 100644 --- a/resources/views/components/applications/links.blade.php +++ b/resources/views/components/applications/links.blade.php @@ -19,7 +19,7 @@ @foreach (Str::of(data_get($application, 'fqdn'))->explode(',') as $fqdn)
  • + target="_blank" href="{{ getFqdnWithoutPort($fqdn) }}"> @@ -28,7 +28,7 @@ - {{ getOnlyFqdn($fqdn) }} + {{ getFqdnWithoutPort($fqdn) }}
  • @endforeach @@ -38,7 +38,7 @@ @if (data_get($preview, 'fqdn'))
  • + target="_blank" href="{{ getFqdnWithoutPort(data_get($preview, 'fqdn')) }}"> From 0c35726a8d1777c2e63ae92b2919ca3430a40b39 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 17:47:43 +0200 Subject: [PATCH 05/12] fix: add traefik labels no matter if traefik is selected or not --- bootstrap/helpers/docker.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 6d8e2e024..27fa96fb8 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -147,7 +147,7 @@ function fqdnLabelsForTraefik(Collection $domains, $container_name, $is_force_ht { $labels = collect([]); $labels->push('traefik.enable=true'); - foreach($domains as $domain) { + foreach ($domains as $domain) { $url = Url::fromString($domain); $host = $url->getHost(); $path = $url->getPath(); @@ -216,9 +216,8 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview } else { $domains = Str::of(data_get($application, 'fqdn'))->explode(','); } - if ($application->destination->server->proxy->type === ProxyTypes::TRAEFIK_V2->value) { - $labels = $labels->merge(fqdnLabelsForTraefik($domains, $container_name, $application->settings->is_force_https_enabled)); - } + // Add Traefik labels no matter which proxy is selected + $labels = $labels->merge(fqdnLabelsForTraefik($domains, $container_name, $application->settings->is_force_https_enabled)); } return $labels->all(); } From 5b877b84c2511266cad4d56d3f3db262a188551b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 17:48:25 +0200 Subject: [PATCH 06/12] fix: add expose port for containers --- app/Jobs/ApplicationDeploymentJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index ee2f01b74..a4c37a084 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -529,7 +529,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted 'restart' => RESTART_MODE, 'environment' => $environment_variables, 'labels' => generateLabelsApplication($this->application, $this->preview), - // 'expose' => $ports, + 'expose' => $ports, 'networks' => [ $this->destination->network, ], From 0509da6730b3199d4360c8a2c4b06a11cb35877d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 17:48:40 +0200 Subject: [PATCH 07/12] fix: also check docker socks permission on validation --- bootstrap/helpers/remoteProcess.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 0d76d46ea..e5a2a5863 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -189,7 +189,7 @@ function validateServer(Server $server, bool $throwError = false) ]; } $server->settings->is_reachable = true; - + instant_remote_process(["docker ps"], $server, $throwError); $dockerVersion = instant_remote_process(["docker version|head -2|grep -i version| awk '{print $2}'"], $server, $throwError); if (!$dockerVersion) { $dockerVersion = null; From 6138ddcac637f98d172ce99675e390681c98d4ee Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 17:51:01 +0200 Subject: [PATCH 08/12] revert sending notification --- app/Jobs/ContainerStatusJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 68f4269a6..1067d0028 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -258,7 +258,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted $this->server->team->notify(new ContainerStopped($containerName, $this->server, $url)); } } catch (\Throwable $e) { - // send_internal_notification('ContainerStatusJob failed with: ' . $e->getMessage()); + send_internal_notification('ContainerStatusJob failed with: ' . $e->getMessage()); ray($e->getMessage()); throw $e; } From ea6ec07a4505c1e2e986324c8bb036c43391e625 Mon Sep 17 00:00:00 2001 From: Chingiz Mammadov Date: Sun, 24 Sep 2023 23:03:11 +0400 Subject: [PATCH 09/12] ui: Fixed z-index for magicbar --- resources/views/layouts/app.blade.php | 2 +- resources/views/layouts/subscription.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index e825b5493..00c8b7b87 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -2,7 +2,7 @@ @section('body') @parent -
    +
    diff --git a/resources/views/layouts/subscription.blade.php b/resources/views/layouts/subscription.blade.php index 2feb5199b..1ece2d7ee 100644 --- a/resources/views/layouts/subscription.blade.php +++ b/resources/views/layouts/subscription.blade.php @@ -2,7 +2,7 @@ @section('body') @parent @if (isSubscriptionOnGracePeriod()) -
    +
    From 5f0c9c3a315ee9db3b0e0ce4075ea2f1946d0227 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 21:15:21 +0200 Subject: [PATCH 10/12] ui: Add source button --- resources/views/source/all.blade.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/views/source/all.blade.php b/resources/views/source/all.blade.php index 9c82fec0c..e04c948ae 100644 --- a/resources/views/source/all.blade.php +++ b/resources/views/source/all.blade.php @@ -1,5 +1,10 @@ -

    Sources

    +
    All Sources
    @forelse ($sources as $source) From b02e5d3f27e5246fe7899048b0bdd48e3e81e170 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 21:15:43 +0200 Subject: [PATCH 11/12] fix: applications with port mappins do a normal update (not rolling update) --- app/Jobs/ApplicationDeploymentJob.php | 23 ++++++++++++++----- .../project/application/general.blade.php | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index a4c37a084..eeabb185f 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -284,9 +284,20 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private function rolling_update() { - $this->start_by_compose_file(); - $this->health_check(); - $this->stop_running_container(); + if (count($this->application->ports_mappings_array) > 0){ + $this->execute_remote_command( + ["echo -n 'Application has ports mapped to the host system, rolling update is not supported. Stopping current container.'"], + ); + $this->stop_running_container(force: true); + $this->start_by_compose_file(); + } else { + $this->execute_remote_command( + ["echo -n 'Rolling update started.'"], + ); + $this->start_by_compose_file(); + $this->health_check(); + $this->stop_running_container(); + } } private function health_check() { @@ -704,10 +715,10 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } } - private function stop_running_container() + private function stop_running_container(bool $force = false) { if ($this->currently_running_container_name) { - if ($this->newVersionIsHealthy) { + if ($this->newVersionIsHealthy || $force) { $this->execute_remote_command( ["echo -n 'Removing old version of your application.'"], [executeInDocker($this->deployment_uuid, "docker rm -f $this->currently_running_container_name >/dev/null 2>&1"), "hidden" => true], @@ -724,7 +735,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); private function start_by_compose_file() { $this->execute_remote_command( - ["echo -n 'Rolling update started.'"], + ["echo -n 'Starting application (could take a while).'"], [executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up -d >/dev/null"), "hidden" => true], ); } diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index a0089079a..5d789edcf 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -63,7 +63,7 @@ helper="A comma separated list of ports your application uses. The first port will be used as default healthcheck port if nothing defined in the Healthcheck menu. Be sure to set this correctly." /> @endif + helper="A comma separated list of ports you would like to map to the host system. Useful when you do not want to use domains.

    Example:
    3000:3000,3002:3002

    Rolling update is not supported if you have a port mapped to the host." />

    Advanced

    From 4fc8988ff4af3b28253fdfec701f8275ffcb74e4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 21:38:11 +0200 Subject: [PATCH 12/12] fix: put back build pack chooser --- .../views/livewire/project/application/general.blade.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 5d789edcf..ca3fb7a6e 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -26,6 +26,14 @@ @endif @endif
    + @if (!$application->dockerfile) +
    + + + + +
    + @endif @if ($application->settings->is_static) @@ -54,6 +62,7 @@ @if ($application->dockerfile) @endif +

    Network

    @if ($application->settings->is_static)