Add custom_healthcheck_found flag to ApplicationDeploymentJob

This commit is contained in:
Andras Bacsai 2024-03-13 10:50:05 +01:00
parent aef088a9d2
commit 0d4ad05c1c

View File

@ -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 @@ private function health_check()
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 @@ private function generate_compose_file()
$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 @@ private function generate_compose_file()
]
]
];
if (!$custom_healthcheck_found) {
if (!$this->custom_healthcheck_found) {
$docker_compose['services'][$this->container_name]['healthcheck'] = [
'test' => [
'CMD-SHELL',