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
fix: show Traefik version warnings before detection completes
Andras Bacsai2e928d86d86c
diff --git a/app/Livewire/Server/Proxy.php b/app/Livewire/Server/Proxy.phpindex 0454d97049..a3f9be2db5 100644--- a/app/Livewire/Server/Proxy.php+++ b/app/Livewire/Server/Proxy.php@@ -189,11 +189,30 @@ class Proxy extends Component{try {$this->proxySettings = GetProxyConfiguration::run($this->server);+ $this->clearAppliedTraefikBranchWarning();} catch (\Throwable $e) {return handleError($e, $this);}}+ public function getTraefikVersionForWarningProperty(): ?string+ {+ if ($this->server->detected_traefik_version) {+ return $this->server->detected_traefik_version;+ }++ if ($this->server->proxy->get('status') !== 'running' || $this->server->hasPendingProxyConfiguration()) {+ return null;+ }++ $configuration = $this->server->proxy->get('last_saved_proxy_configuration');+ if (! is_string($configuration) || ! preg_match('/^\s*image:\s*[\'\"]?traefik:(v?\d+\.\d+(?:\.\d+)?|latest)[\'\"]?\s*$/mi', $configuration, $matches)) {+ return null;+ }++ return $matches[1];+ }+/*** Get the latest Traefik version for this server's current branch.*@@ -211,7 +230,7 @@ class Proxy extends Component}// Get this server's current version- $currentVersion = $this->server->detected_traefik_version;+ $currentVersion = $this->traefikVersionForWarning;// If we have a current version, try to find matching branchif ($currentVersion && $currentVersion !== 'latest') {@@ -244,7 +263,7 @@ class Proxy extends Componentreturn false;}- $currentVersion = $this->server->detected_traefik_version;+ $currentVersion = $this->traefikVersionForWarning;if (! $currentVersion || $currentVersion === 'latest') {return false;}@@ -273,7 +292,7 @@ class Proxy extends Component}// Get this server's current version- $currentVersion = $this->server->detected_traefik_version;+ $currentVersion = $this->traefikVersionForWarning;if (! $currentVersion || $currentVersion === 'latest') {return null;}@@ -335,6 +354,14 @@ class Proxy extends Component}}+ public function getLatestNewerTraefikVersionProperty(): ?string+ {+ $branch = $this->newerTraefikBranchAvailable;+ $version = $branch ? ($this->getTraefikVersions()[$branch] ?? null) : null;++ return $version ? 'v'.ltrim($version, 'v') : null;+ }+private function getConfiguredTraefikBranch(): ?string{if ($this->server->proxy->get('status') !== 'running' || $this->server->hasPendingProxyConfiguration()) {diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.phpindex 1d4033ea1a..5a6e514da6 100644--- a/resources/views/livewire/server/proxy.blade.php+++ b/resources/views/livewire/server/proxy.blade.php@@ -110,21 +110,26 @@</x-slot:actions>@if ($server->proxyType() === ProxyTypes::TRAEFIK->value)- @if ($server->detected_traefik_version === 'latest')+ @if ($this->traefikVersionForWarning === 'latest')<x-callout type="warning" title="Unpinned Traefik version">The proxy uses the <span class="font-mono">latest</span> tag. Pin<span class="font-mono">traefik:{{ $this->latestTraefikVersion }}</span>for predictable updates.</x-callout>- @elseif($this->isTraefikOutdated)+ @endif+ @if ($this->isTraefikOutdated)<x-callout type="warning" title="Traefik patch update available">- Version {{ $this->latestTraefikVersion }} is available. Test the update before- applying it to production servers.+ {{ $server->detected_traefik_version ? 'Running version' : 'Configured image' }}+ v{{ ltrim($this->traefikVersionForWarning, 'v') }}. The latest patch+ for this branch is {{ $this->latestTraefikVersion }}. Test the update before applying it+ to production servers.</x-callout>- @elseif($this->newerTraefikBranchAvailable)+ @endif+ @if ($this->newerTraefikBranchAvailable)<x-callout type="info" title="New Traefik minor version available">- {{ $this->newerTraefikBranchAvailable }} is available. Review the Traefik- changelog for breaking changes before upgrading.+ {{ $this->newerTraefikBranchAvailable }} is available (latest patch:+ {{ $this->latestNewerTraefikVersion }}). Review the Traefik changelog for breaking+ changes before upgrading.</x-callout>@endif@endifdiff --git a/tests/Feature/TraefikVersionStateTest.php b/tests/Feature/TraefikVersionStateTest.phpindex de3cf8e17c..c3388e3a02 100644--- a/tests/Feature/TraefikVersionStateTest.php+++ b/tests/Feature/TraefikVersionStateTest.php@@ -7,13 +7,94 @@ use App\Jobs\CheckTraefikVersionJob;use App\Livewire\Server\Proxy;use App\Models\Server;use App\Models\Team;+use App\Models\User;use Illuminate\Foundation\Testing\RefreshDatabase;use Illuminate\Support\Facades\Bus;use Illuminate\Support\Facades\Cache;use Illuminate\Support\Facades\Event;+use Livewire\Livewire;uses(RefreshDatabase::class);+it('shows patch and minor upgrade warnings on the first proxy render', function () {+ Cache::put('coolify:versions:all', [+ 'traefik' => [+ 'v3.7' => '3.7.13',+ 'v3.6' => '3.6.25',+ ],+ ]);++ $team = Team::factory()->create();+ $user = User::factory()->create();+ $team->members()->attach($user->id, ['role' => 'owner']);+ session(['currentTeam' => $team]);+ $this->actingAs($user);++ $server = Server::factory()->create([+ 'team_id' => $team->id,+ 'proxy' => ['type' => ProxyTypes::TRAEFIK->value, 'status' => 'running'],+ 'detected_traefik_version' => '3.6.1',+ 'traefik_outdated_info' => [+ 'current' => '3.6.1',+ 'latest' => '3.7.13',+ 'type' => 'minor_upgrade',+ 'upgrade_target' => 'v3.7',+ ],+ ]);++ Livewire::test(Proxy::class, ['server' => $server])+ ->assertSee('Traefik patch update available')+ ->assertSee('v3.6.25')+ ->assertSee('New Traefik minor version available')+ ->assertSee('v3.7.13');+});++it('shows a warning from the saved image before version detection finishes', function () {+ Cache::put('coolify:versions:all', [+ 'traefik' => ['v3.7' => '3.7.13', 'v3.6' => '3.6.25'],+ ]);++ $team = Team::factory()->create();+ $user = User::factory()->create();+ $team->members()->attach($user->id, ['role' => 'owner']);+ session(['currentTeam' => $team]);+ $this->actingAs($user);++ $server = Server::factory()->create([+ 'team_id' => $team->id,+ 'proxy' => [+ 'type' => ProxyTypes::TRAEFIK->value,+ 'status' => 'running',+ 'last_saved_proxy_configuration' => "services:\n traefik:\n image: 'traefik:v3.6.5'",+ ],+ 'detected_traefik_version' => null,+ ]);++ Livewire::test(Proxy::class, ['server' => $server])+ ->assertSee('Configured image')+ ->assertSee('v3.6.5')+ ->assertSee('v3.6.25')+ ->assertSee('v3.7.13');+});++it('does not treat an unapplied image as the running Traefik version', function () {+ $server = Server::factory()->make([+ 'proxy' => [+ 'type' => ProxyTypes::TRAEFIK->value,+ 'status' => 'running',+ 'last_saved_settings' => 'new',+ 'last_applied_settings' => 'old',+ 'last_saved_proxy_configuration' => "services:\n traefik:\n image: traefik:v3.6.5",+ ],+ 'detected_traefik_version' => null,+ ]);++ $component = new Proxy;+ $component->server = $server;++ expect($component->getTraefikVersionForWarningProperty())->toBeNull();+});+it('ignores stale minor upgrade information for the detected Traefik version', function () {Cache::put('coolify:versions:all', ['traefik' => [@@ -120,6 +201,7 @@ YAML,$component = new Proxy;$component->server = $server;$component->mount();+ $component->loadProxyConfiguration();expect($server->refresh()->traefik_outdated_info)->toBeNull();});