mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(healthcheck): keep the Dockerfile HEALTHCHECK of existing applications
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fd5efd0273
commit
afe8fc05ea
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Until v4.5.0, a HEALTHCHECK in the Dockerfile was used even when the Coolify healthcheck was enabled.
|
||||
* Since v4.5.1 an enabled Coolify healthcheck replaces it. Existing applications with a Dockerfile
|
||||
* HEALTHCHECK get the Coolify healthcheck disabled, so their deployments keep the Dockerfile healthcheck.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('applications')
|
||||
->where('custom_healthcheck_found', true)
|
||||
->where('health_check_enabled', true)
|
||||
->update(['health_check_enabled' => false]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// This data migration cannot identify which applications had the Coolify healthcheck enabled.
|
||||
}
|
||||
};
|
||||
@@ -26,9 +26,16 @@
|
||||
|
||||
@if ($customHealthcheckFound)
|
||||
<div class="mb-4">
|
||||
<x-callout type="warning" title="Custom healthcheck detected">
|
||||
Enabling this configuration replaces the custom healthcheck currently defined by the application.
|
||||
</x-callout>
|
||||
@if ($healthCheckEnabled)
|
||||
<x-callout type="warning" title="Dockerfile HEALTHCHECK replaced">
|
||||
This healthcheck replaces the HEALTHCHECK from the Dockerfile. Disable it to use the
|
||||
Dockerfile HEALTHCHECK again.
|
||||
</x-callout>
|
||||
@else
|
||||
<x-callout type="info" title="Dockerfile HEALTHCHECK in use">
|
||||
The application uses the HEALTHCHECK from its Dockerfile. Enabling this healthcheck replaces it.
|
||||
</x-callout>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Project\Shared\HealthChecks;
|
||||
use App\Models\Application;
|
||||
use App\Models\InstanceSettings;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Server::flushIdentityMap();
|
||||
InstanceSettings::forceCreate(['id' => 0]);
|
||||
|
||||
$team = Team::factory()->create();
|
||||
$this->healthcheckMigrationOwner = User::factory()->create();
|
||||
$team->members()->attach($this->healthcheckMigrationOwner->id, ['role' => 'owner']);
|
||||
$project = Project::factory()->create(['team_id' => $team->id]);
|
||||
$server = Server::factory()->create(['team_id' => $team->id]);
|
||||
$this->healthcheckMigrationEnvironment = $project->environments()->firstOrFail();
|
||||
$this->healthcheckMigrationDestination = StandaloneDocker::query()->where('server_id', $server->id)->firstOrFail();
|
||||
});
|
||||
|
||||
function keepDockerfileHealthcheckApplication(bool $healthCheckEnabled, bool $customHealthcheckFound): Application
|
||||
{
|
||||
return Application::factory()->create([
|
||||
'environment_id' => test()->healthcheckMigrationEnvironment->id,
|
||||
'destination_id' => test()->healthcheckMigrationDestination->id,
|
||||
'destination_type' => StandaloneDocker::class,
|
||||
'build_pack' => 'dockerfile',
|
||||
'health_check_enabled' => $healthCheckEnabled,
|
||||
'custom_healthcheck_found' => $customHealthcheckFound,
|
||||
])->fresh();
|
||||
}
|
||||
|
||||
test('disables the Coolify healthcheck only for applications with a Dockerfile HEALTHCHECK', function () {
|
||||
$dockerfileAndCoolify = keepDockerfileHealthcheckApplication(healthCheckEnabled: true, customHealthcheckFound: true);
|
||||
$dockerfileOnly = keepDockerfileHealthcheckApplication(healthCheckEnabled: false, customHealthcheckFound: true);
|
||||
$coolifyOnly = keepDockerfileHealthcheckApplication(healthCheckEnabled: true, customHealthcheckFound: false);
|
||||
$none = keepDockerfileHealthcheckApplication(healthCheckEnabled: false, customHealthcheckFound: false);
|
||||
|
||||
(require database_path('migrations/2026_10_28_124421_keep_dockerfile_healthcheck_for_existing_applications.php'))->up();
|
||||
|
||||
expect($dockerfileAndCoolify->fresh()->health_check_enabled)->toBeFalse()
|
||||
->and($dockerfileAndCoolify->fresh()->custom_healthcheck_found)->toBeTrue()
|
||||
->and($dockerfileOnly->fresh()->health_check_enabled)->toBeFalse()
|
||||
->and($coolifyOnly->fresh()->health_check_enabled)->toBeTrue()
|
||||
->and($none->fresh()->health_check_enabled)->toBeFalse();
|
||||
});
|
||||
|
||||
test('the healthcheck page says whether the Dockerfile HEALTHCHECK is in use or replaced', function () {
|
||||
$this->actingAs($this->healthcheckMigrationOwner);
|
||||
|
||||
Livewire::test(HealthChecks::class, ['resource' => keepDockerfileHealthcheckApplication(healthCheckEnabled: false, customHealthcheckFound: true)])
|
||||
->assertSee('Dockerfile HEALTHCHECK in use')
|
||||
->assertDontSee('Dockerfile HEALTHCHECK replaced');
|
||||
|
||||
Livewire::test(HealthChecks::class, ['resource' => keepDockerfileHealthcheckApplication(healthCheckEnabled: true, customHealthcheckFound: true)])
|
||||
->assertSee('Dockerfile HEALTHCHECK replaced')
|
||||
->assertDontSee('Dockerfile HEALTHCHECK in use');
|
||||
|
||||
Livewire::test(HealthChecks::class, ['resource' => keepDockerfileHealthcheckApplication(healthCheckEnabled: true, customHealthcheckFound: false)])
|
||||
->assertDontSee('Dockerfile HEALTHCHECK');
|
||||
});
|
||||
Reference in New Issue
Block a user