From 0d4ad05c1c6e4189efc0592b2336be45b965e492 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 13 Mar 2024 10:50:05 +0100 Subject: [PATCH] Add custom_healthcheck_found flag to ApplicationDeploymentJob --- app/Jobs/ApplicationDeploymentJob.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index a8cda71a5..3e6230336 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -92,6 +92,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private ?string $buildTarget = null; private Collection $saved_outputs; private ?string $full_healthcheck_url = null; + private bool $custom_healthcheck_found = false; private string $serverUser = 'root'; private string $serverUserHomeDir = '/root'; @@ -775,7 +776,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted if ($this->server->isSwarm()) { // Implement healthcheck for swarm } else { - if ($this->application->isHealthcheckDisabled()) { + if ($this->application->isHealthcheckDisabled() && $this->custom_healthcheck_found === false) { $this->newVersionIsHealthy = true; return; } @@ -1121,14 +1122,14 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $labels = $labels->merge(defaultLabels($this->application->id, $this->application->uuid, $this->pull_request_id))->toArray(); // Check for custom HEALTHCHECK - $custom_healthcheck_found = false; - if ($this->application->build_pack === 'dockerfile') { + $this->custom_healthcheck_found = false; + if ($this->application->build_pack === 'dockerfile' || $this->application->dockerfile) { $this->execute_remote_command([ executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"), "hidden" => true, "save" => 'dockerfile', "ignore_errors" => true ]); $dockerfile = collect(Str::of($this->saved_outputs->get('dockerfile'))->trim()->explode("\n")); if (str($dockerfile)->contains('HEALTHCHECK')) { - $custom_healthcheck_found = true; + $this->custom_healthcheck_found = true; } } $docker_compose = [ @@ -1160,7 +1161,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted ] ] ]; - if (!$custom_healthcheck_found) { + if (!$this->custom_healthcheck_found) { $docker_compose['services'][$this->container_name]['healthcheck'] = [ 'test' => [ 'CMD-SHELL',