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(application): show the default file location when the field is empty or cleared
peaklabs-dev650351e2dad7
diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex 531aa834c0..0f0f68e9b4 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -436,7 +436,7 @@ class General extends Component$this->portsMappings = $this->application->ports_mappings;$this->customNetworkAliases = $this->application->custom_network_aliases;$this->dockerfile = $this->application->dockerfile;- $this->dockerfileLocation = $this->application->dockerfile_location;+ $this->dockerfileLocation = $this->application->dockerfile_location ?? ($this->buildPack === 'dockerfile' ? '/Dockerfile' : null);$this->dockerfileTargetBuild = $this->application->dockerfile_target_build;$this->dockerRegistryImageName = $this->application->docker_registry_image_name;$this->dockerRegistryImageTag = $this->application->docker_registry_image_tag;diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex 1df2bedfb2..e0ec7b5add 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -159,7 +159,8 @@this.baseDir = this.normalizePath(this.baseDir);},normalizeComposeLocation() {- this.composeLocation = this.normalizePath(this.composeLocation);+ const path = this.normalizePath(this.composeLocation);+ this.composeLocation = path === '/' ? '/docker-compose.yaml' : path;}}" class="grid gap-4 lg:grid-cols-2"><x-forms.input x-bind:disabled="shouldDisable()" placeholder="/"@@ -230,7 +231,8 @@this.baseDir = this.normalizePath(this.baseDir);},normalizeDockerfileLocation() {- this.dockerfileLocation = this.normalizePath(this.dockerfileLocation);+ const path = this.normalizePath(this.dockerfileLocation);+ this.dockerfileLocation = path === '/' ? '/Dockerfile' : path;}}" class="grid gap-4 lg:grid-cols-2"><x-forms.input placeholder="/"diff --git a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.phpindex b0dc41bb4d..11e5ca96f2 100644--- a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php+++ b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php@@ -92,7 +92,7 @@<x-forms.input placeholder="/docker-compose.yaml"wire:model.defer="docker_compose_location" label="Compose file"helper="Path relative to the base directory." x-model="composeLocation"- @blur="composeLocation = normalize(composeLocation)" />+ @blur="composeLocation = normalize(composeLocation).replace(/^\/$/, '/docker-compose.yaml')" /><p class="sm:col-span-2 text-xs text-neutral-500 dark:text-fg-dim">Resolved file:<code class="font-mono text-coollabs dark:text-warning"diff --git a/resources/views/livewire/project/new/github-private-repository.blade.php b/resources/views/livewire/project/new/github-private-repository.blade.phpindex 26aaf3530f..22be530c95 100644--- a/resources/views/livewire/project/new/github-private-repository.blade.php+++ b/resources/views/livewire/project/new/github-private-repository.blade.php@@ -150,7 +150,7 @@<x-forms.input placeholder="/docker-compose.yaml"wire:model.defer="docker_compose_location" label="Compose file"helper="Path relative to the base directory." x-model="composeLocation"- @blur="composeLocation = normalize(composeLocation)" />+ @blur="composeLocation = normalize(composeLocation).replace(/^\/$/, '/docker-compose.yaml')" /><p class="sm:col-span-2 text-xs text-neutral-500 dark:text-fg-dim">Resolved file:<code class="font-mono text-coollabs dark:text-warning"diff --git a/resources/views/livewire/project/new/gitlab-private-repository.blade.php b/resources/views/livewire/project/new/gitlab-private-repository.blade.phpindex 8a88bf60c3..4060fff309 100644--- a/resources/views/livewire/project/new/gitlab-private-repository.blade.php+++ b/resources/views/livewire/project/new/gitlab-private-repository.blade.php@@ -148,7 +148,7 @@<x-forms.input placeholder="/docker-compose.yaml"wire:model.defer="docker_compose_location" label="Compose file"helper="Path relative to the base directory." x-model="composeLocation"- @blur="composeLocation = normalize(composeLocation)" />+ @blur="composeLocation = normalize(composeLocation).replace(/^\/$/, '/docker-compose.yaml')" /><p class="sm:col-span-2 text-xs text-neutral-500 dark:text-fg-dim">Resolved file:<code class="font-mono text-coollabs dark:text-warning"diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.phpindex 137d880eed..7e120b8539 100644--- a/resources/views/livewire/project/new/public-git-repository.blade.php+++ b/resources/views/livewire/project/new/public-git-repository.blade.php@@ -99,7 +99,7 @@<x-forms.input placeholder="/docker-compose.yaml"wire:model.defer="docker_compose_location" label="Compose file"helper="Path relative to the base directory." x-model="composeLocation"- @blur="composeLocation = normalize(composeLocation)" />+ @blur="composeLocation = normalize(composeLocation).replace(/^\/$/, '/docker-compose.yaml')" /><p class="sm:col-span-2 text-xs text-neutral-500 dark:text-fg-dim">Resolved file:<code class="font-mono text-coollabs dark:text-warning"diff --git a/tests/Feature/ApplicationGeneralBuildpackSelectorTest.php b/tests/Feature/ApplicationGeneralBuildpackSelectorTest.phpindex d842d7c546..3d163f1a81 100644--- a/tests/Feature/ApplicationGeneralBuildpackSelectorTest.php+++ b/tests/Feature/ApplicationGeneralBuildpackSelectorTest.php@@ -122,6 +122,26 @@ test('switching from railpack to compose preserves the existing application doma->toBe('https://example.com,https://www.example.com');});+test('Dockerfile location defaults to the Dockerfile only for the Dockerfile build pack', function (string $buildPack, ?string $expected) {+ $application = Application::factory()->create([+ 'environment_id' => $this->environment->id,+ 'destination_id' => $this->destination->id,+ 'destination_type' => StandaloneDocker::class,+ 'build_pack' => $buildPack,+ 'static_image' => 'nginx:alpine',+ 'base_directory' => '/',+ 'is_http_basic_auth_enabled' => false,+ 'redirect' => 'no',+ ]);++ Livewire::test(General::class, ['application' => $application])+ ->assertSuccessful()+ ->assertSet('dockerfileLocation', $expected);+})->with([+ 'Dockerfile' => ['dockerfile', '/Dockerfile'],+ 'Nixpacks' => ['nixpacks', null],+]);+test('networking section hints that internal ports can be set per domain', function () {$application = Application::factory()->create(['environment_id' => $this->environment->id,diff --git a/tests/v4/Browser/ApplicationConfigurationTest.php b/tests/v4/Browser/ApplicationConfigurationTest.phpindex cb60e12949..f7778b501b 100644--- a/tests/v4/Browser/ApplicationConfigurationTest.php+++ b/tests/v4/Browser/ApplicationConfigurationTest.php@@ -156,6 +156,27 @@ it('saves custom docker run options from the UI', function () {->screenshot(filename: 'application-docker-run-options');});+it('restores the default file location when the field is cleared', function (string $buildPack, string $column, string $default) {+ $this->application->update(['build_pack' => $buildPack, $column => '/docker/custom']);++ loginAndSkipBoarding();++ $page = visit(applicationConfigurationUrl(+ $this->stack['project'],+ $this->stack['environment'],+ $this->application+ ));++ $page->clear("input[placeholder='{$default}']")+ ->keys("input[placeholder='{$default}']", 'Tab')+ ->assertValue("input[placeholder='{$default}']", $default)+ ->assertNoJavaScriptErrors()+ ->screenshot(filename: "application-{$buildPack}-location-cleared");+})->with([+ 'Dockerfile' => ['dockerfile', 'dockerfile_location', '/Dockerfile'],+ 'Docker Compose' => ['dockercompose', 'docker_compose_location', '/docker-compose.yaml'],+]);+it('opens environment variables page for the application', function () {loginAndSkipBoarding();diff --git a/tests/v4/Browser/NewApplicationRepositoryPathsTest.php b/tests/v4/Browser/NewApplicationRepositoryPathsTest.phpnew file mode 100644index 0000000000..f7970fd02a--- /dev/null+++ b/tests/v4/Browser/NewApplicationRepositoryPathsTest.php@@ -0,0 +1,24 @@+<?php++use Illuminate\Foundation\Testing\RefreshDatabase;++uses(RefreshDatabase::class);++it('restores the default compose file when the field is cleared', function () {+ $stack = seedBrowserResourceStack();+ loginAndSkipBoarding();++ $page = visit("/project/{$stack['project']->uuid}/environment/{$stack['environment']->uuid}/new?type=public&destination={$stack['destination']->uuid}");++ $page->fill('repository_url', 'https://gitlab.com/example/monorepo.git')+ ->click('Check repository')+ ->assertSee('Build configuration');++ selectListboxOption($page, 'build_pack', 'Docker Compose');++ $page->clear("input[placeholder='/docker-compose.yaml']")+ ->keys("input[placeholder='/docker-compose.yaml']", 'Tab')+ ->assertValue("input[placeholder='/docker-compose.yaml']", '/docker-compose.yaml')+ ->assertNoJavaScriptErrors()+ ->screenshot(filename: 'new-application-compose-file-cleared');+});