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(ports): skip the PORT mismatch warning when readonly labels are disabled
Andras Bacsaiea1b701a9471
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 3a00704813..ea3ce9191c 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -1927,8 +1927,9 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue$envs->push($this->runtimeEnvironmentAssignment($env));}- // Check for PORT environment variable mismatch with ports_exposes- if ($this->build_pack !== 'dockercompose') {+ // Check for PORT environment variable mismatch with ports_exposes.+ // With readonly labels disabled, custom labels control proxy routing, so skip the check.+ if ($this->build_pack !== 'dockercompose' && $this->application->settings->is_container_label_readonly_enabled) {$detectedPort = $this->application->detectPortFromEnvironment(false);if ($detectedPort && ! empty($ports) && ! in_array($detectedPort, $ports)) {$this->application_deployment_queue->addLogEntry(diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex 09a634c681..a58d87f307 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -992,6 +992,11 @@ class General extends Componentpublic function getDetectedPortInfoProperty(): ?array{+ // With readonly labels disabled, Ports Exposes is read-only and custom labels control proxy routing.+ if (! $this->application->settings->is_container_label_readonly_enabled) {+ return null;+ }+$detectedPort = $this->application->detectPortFromEnvironment();if (! $detectedPort) {diff --git a/tests/Feature/ApplicationDeploymentControlVarFilteringTest.php b/tests/Feature/ApplicationDeploymentControlVarFilteringTest.phpindex d19a382e0e..caf92c69e4 100644--- a/tests/Feature/ApplicationDeploymentControlVarFilteringTest.php+++ b/tests/Feature/ApplicationDeploymentControlVarFilteringTest.php@@ -2029,3 +2029,24 @@ it('keeps heredoc bodies unchanged when it adds build secrets to a Dockerfile',"RUN --mount=type=secret,id=API_URL,env=API_URL python -c 'print(1)'",]);});++it('warns in the deployment log when PORT does not match ports_exposes', function () {+ [$application, $server] = makeDeploymentControlVarFixture(['ports_exposes' => '80']);+ createApplicationEnvironmentVariable($application, ['key' => 'PORT', 'value' => '3000']);++ [$job, $reflection] = makeControlVarFilteringJob($application, $server);+ invokeDeploymentJobMethod($job, $reflection, 'generate_runtime_environment_variables');++ expect(collect($job->recordedLogEntries)->contains(fn (string $entry) => str_contains($entry, 'PORT environment variable (3000)')))->toBeTrue();+});++it('does not warn about a PORT mismatch when readonly labels are disabled', function () {+ [$application, $server] = makeDeploymentControlVarFixture(['ports_exposes' => '80']);+ $application->settings()->update(['is_container_label_readonly_enabled' => false]);+ createApplicationEnvironmentVariable($application, ['key' => 'PORT', 'value' => '3000']);++ [$job, $reflection] = makeControlVarFilteringJob($application, $server);+ invokeDeploymentJobMethod($job, $reflection, 'generate_runtime_environment_variables');++ expect(collect($job->recordedLogEntries)->contains(fn (string $entry) => str_contains($entry, 'PORT environment variable')))->toBeFalse();+});diff --git a/tests/Feature/ApplicationPortMismatchWarningTest.php b/tests/Feature/ApplicationPortMismatchWarningTest.phpnew file mode 100644index 0000000000..c47de2718b--- /dev/null+++ b/tests/Feature/ApplicationPortMismatchWarningTest.php@@ -0,0 +1,66 @@+<?php++use App\Livewire\Project\Application\General;+use App\Models\Application;+use App\Models\Environment;+use App\Models\EnvironmentVariable;+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 () {+ $this->team = Team::factory()->create();+ $this->user = User::factory()->create();+ $this->team->members()->attach($this->user->id, ['role' => 'owner']);++ $this->actingAs($this->user);+ session(['currentTeam' => $this->team]);+ InstanceSettings::unguarded(function () {+ InstanceSettings::updateOrCreate(['id' => 0], []);+ });++ $project = Project::factory()->create(['team_id' => $this->team->id]);+ $environment = Environment::factory()->create(['project_id' => $project->id]);+ $server = Server::factory()->create(['team_id' => $this->team->id]);+ $destination = StandaloneDocker::where('server_id', $server->id)->first()+ ?? StandaloneDocker::factory()->create(['server_id' => $server->id, 'network' => 'coolify-test']);++ $this->application = Application::factory()->create([+ 'environment_id' => $environment->id,+ 'destination_id' => $destination->id,+ 'destination_type' => StandaloneDocker::class,+ 'build_pack' => 'dockerimage',+ 'ports_exposes' => '80',+ ]);++ EnvironmentVariable::create([+ 'key' => 'PORT',+ 'value' => '3000',+ 'resourceable_type' => Application::class,+ 'resourceable_id' => $this->application->id,+ 'is_preview' => false,+ ]);+});++test('shows a PORT mismatch warning when readonly labels are enabled', function () {+ Livewire::test(General::class, ['application' => $this->application->fresh()])+ ->assertSee('PORT mismatch detected');+});++/**+ * Regression for #10941: with readonly labels disabled, the Ports Exposes field is+ * read-only and custom labels control proxy routing, so the warning cannot be acted on.+ */+test('does not show a PORT mismatch warning when readonly labels are disabled', function () {+ $this->application->settings()->update(['is_container_label_readonly_enabled' => false]);++ Livewire::test(General::class, ['application' => $this->application->fresh()])+ ->assertDontSee('PORT mismatch detected');+});