An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: able to disable container healthchecks fix: dockerfile based deployments have hc off by default
Andras Bacsai0e1bcceb8edf
diff --git a/app/Http/Livewire/Project/New/SimpleDockerfile.php b/app/Http/Livewire/Project/New/SimpleDockerfile.phpindex 8a1d2c024e..07a9ec88a2 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.phpindex 62a0d8dc0a..1c783abecd 100644--- a/app/Http/Livewire/Project/Shared/HealthChecks.php+++ b/app/Http/Livewire/Project/Shared/HealthChecks.php@@ -9,6 +9,7 @@ class HealthChecks extends Componentpublic $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.phpindex 69d385445c..f9ff54fd09 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.phpindex 59b67fa164..224b332cc8 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.phpnew file mode 100644index 0000000000..4b8eeea08d--- /dev/null+++ b/database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php@@ -0,0 +1,28 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('applications', function (Blueprint $table) {+ $table->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.phpindex c5596d311f..e2ae8879e7 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 @@</div><div class="pb-4">Define how your resource's health should be checked.</div><div class="flex flex-col gap-4">- <div class="flex gap-2">- <x-forms.input id="resource.health_check_method" placeholder="GET" label="Method" required />+ <div class="w-32">+ <x-forms.checkbox instantSave id="resource.health_check_enabled" label="Enabled" />+ </div>+ <div class="flex gap-2">+ <x-forms.input id="resource.health_check_method" placeholder="GET" label="Method" required />- <x-forms.input id="resource.health_check_scheme" placeholder="http" label="Scheme" required />- <x-forms.input id="resource.health_check_host" placeholder="localhost" label="Host" required />- <x-forms.input id="resource.health_check_port"- helper="If no port is defined, the first exposed port will be used." placeholder="80" label="Port" />- <x-forms.input id="resource.health_check_path" placeholder="/health" label="Path" required />+ <x-forms.input id="resource.health_check_scheme" placeholder="http" label="Scheme" required />+ <x-forms.input id="resource.health_check_host" placeholder="localhost" label="Host" required />+ <x-forms.input id="resource.health_check_port"+ helper="If no port is defined, the first exposed port will be used." placeholder="80" label="Port" />+ <x-forms.input id="resource.health_check_path" placeholder="/health" label="Path" required />+ </div>+ <div class="flex gap-2">+ <x-forms.input id="resource.health_check_return_code" placeholder="200" label="Return Code" required />+ <x-forms.input id="resource.health_check_response_text" placeholder="OK" label="Response Text" />+ </div>+ <div class="flex gap-2">+ <x-forms.input id="resource.health_check_interval" placeholder="30" label="Interval" required />+ <x-forms.input id="resource.health_check_timeout" placeholder="30" label="Timeout" required />+ <x-forms.input id="resource.health_check_retries" placeholder="3" label="Retries" required />+ <x-forms.input id="resource.health_check_start_period" placeholder="30" label="Start Period" required />+ </div></div>- <div class="flex gap-2">- <x-forms.input id="resource.health_check_return_code" placeholder="200" label="Return Code" required />- <x-forms.input id="resource.health_check_response_text" placeholder="OK" label="Response Text" />- </div>- <div class="flex gap-2">- <x-forms.input id="resource.health_check_interval" placeholder="30" label="Interval" required />- <x-forms.input id="resource.health_check_timeout" placeholder="30" label="Timeout" required />- <x-forms.input id="resource.health_check_retries" placeholder="3" label="Retries" required />- <x-forms.input id="resource.health_check_start_period" placeholder="30" label="Start Period" required />- </div>-</div></form>