diff --git a/app/Http/Livewire/Project/New/SimpleDockerfile.php b/app/Http/Livewire/Project/New/SimpleDockerfile.php index 8a1d2c024..07a9ec88a 100644 --- a/app/Http/Livewire/Project/New/SimpleDockerfile.php +++ b/app/Http/Livewire/Project/New/SimpleDockerfile.php @@ -59,6 +59,7 @@ CMD ["nginx", "-g", "daemon off;"] 'environment_id' => $environment->id, 'destination_id' => $destination->id, 'destination_type' => $destination_class, + 'health_check_enabled' => false, 'source_id' => 0, 'source_type' => GithubApp::class ]); diff --git a/app/Http/Livewire/Project/Shared/HealthChecks.php b/app/Http/Livewire/Project/Shared/HealthChecks.php index 62a0d8dc0..1c783abec 100644 --- a/app/Http/Livewire/Project/Shared/HealthChecks.php +++ b/app/Http/Livewire/Project/Shared/HealthChecks.php @@ -9,6 +9,7 @@ class HealthChecks extends Component public $resource; protected $rules = [ + 'resource.health_check_enabled' => 'boolean', 'resource.health_check_path' => 'string', 'resource.health_check_port' => 'nullable|string', 'resource.health_check_host' => 'string', @@ -22,12 +23,19 @@ class HealthChecks extends Component 'resource.health_check_start_period' => 'integer', ]; + public function instantSave() + { + $this->resource->save(); + $this->emit('success', 'Health check updated.'); + + + } public function submit() { try { $this->validate(); $this->resource->save(); - $this->emit('saved'); + $this->emit('success', 'Health check updated.'); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 69d385445..f9ff54fd0 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -303,6 +303,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted } private function health_check() { + if ($this->application->isHealthcheckDisabled()) { + $this->newVersionIsHealthy = true; + return; + } ray('New container name: ', $this->container_name); if ($this->container_name) { $counter = 0; @@ -573,6 +577,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted ] ] ]; + if ($this->application->isHealthcheckDisabled()) { + data_forget($docker_compose, 'services.' . $this->container_name . '.healthcheck'); + } if (count($this->application->ports_mappings_array) > 0 && $this->pull_request_id === 0) { $docker_compose['services'][$this->container_name]['ports'] = $this->application->ports_mappings_array; } diff --git a/app/Models/Application.php b/app/Models/Application.php index 59b67fa16..224b332cc 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -231,4 +231,12 @@ class Application extends BaseModel } return true; } + public function isHealthcheckDisabled(): bool + { + if (data_get($this, 'dockerfile') || data_get($this, 'build_pack') === 'dockerfile' || data_get($this,'health_check_enabled') === false) { + ray('dockerfile'); + return true; + } + return false; + } } diff --git a/database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php b/database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php new file mode 100644 index 000000000..4b8eeea08 --- /dev/null +++ b/database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php @@ -0,0 +1,28 @@ +boolean('health_check_enabled')->default(true); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('applications', function (Blueprint $table) { + $table->dropColumn('health_check_enabled'); + }); + } +}; diff --git a/resources/views/livewire/project/shared/health-checks.blade.php b/resources/views/livewire/project/shared/health-checks.blade.php index c5596d311..e2ae8879e 100644 --- a/resources/views/livewire/project/shared/health-checks.blade.php +++ b/resources/views/livewire/project/shared/health-checks.blade.php @@ -5,24 +5,27 @@
Define how your resource's health should be checked.
-
- +
+ +
+
+ - - - - + + + + +
+
+ + +
+
+ + + + +
-
- - -
-
- - - - -
-