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: restore original base_directory on compose validation failure
Andras Bacsaidae680317385
diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex 46a459fe28..c84de9d8d8 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -521,7 +521,7 @@ class General extends Component}}- public function loadComposeFile($isInit = false, $showToast = true)+ public function loadComposeFile($isInit = false, $showToast = true, ?string $restoreBaseDirectory = null, ?string $restoreDockerComposeLocation = null){try {$this->authorize('update', $this->application);@@ -530,7 +530,7 @@ class General extends Componentreturn;}- ['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation] = $this->application->loadComposeFile($isInit);+ ['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation] = $this->application->loadComposeFile($isInit, $restoreBaseDirectory, $restoreDockerComposeLocation);if (is_null($this->parsedServices)) {$showToast && $this->dispatch('error', 'Failed to parse your docker-compose file. Please check the syntax and try again.');@@ -831,13 +831,22 @@ class General extends Componentif ($this->buildPack === 'dockercompose' &&($oldDockerComposeLocation !== $this->dockerComposeLocation ||$oldBaseDirectory !== $this->baseDirectory)) {- $compose_return = $this->loadComposeFile(showToast: false);+ // Pass original values to loadComposeFile so it can restore them on failure+ // The finally block in Application::loadComposeFile will save these original+ // values if validation fails, preventing invalid paths from being persisted+ $compose_return = $this->loadComposeFile(+ isInit: false,+ showToast: false,+ restoreBaseDirectory: $oldBaseDirectory,+ restoreDockerComposeLocation: $oldDockerComposeLocation+ );if ($compose_return instanceof \Livewire\Features\SupportEvents\Event) {- // Restore original values - don't persist invalid data+ // Validation failed - restore original values to component properties$this->baseDirectory = $oldBaseDirectory;$this->dockerComposeLocation = $oldDockerComposeLocation;- $this->application->base_directory = $oldBaseDirectory;- $this->application->docker_compose_location = $oldDockerComposeLocation;+ // The model was saved by loadComposeFile's finally block with original values+ // Refresh to sync component with database state+ $this->application->refresh();return;}diff --git a/app/Models/Application.php b/app/Models/Application.phpindex 6e920f8e69..7bddce32bb 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -1511,9 +1511,11 @@ class Application extends BaseModel}}- public function loadComposeFile($isInit = false)+ public function loadComposeFile($isInit = false, ?string $restoreBaseDirectory = null, ?string $restoreDockerComposeLocation = null){- $initialDockerComposeLocation = $this->docker_compose_location;+ // Use provided restore values or capture current values as fallback+ $initialDockerComposeLocation = $restoreDockerComposeLocation ?? $this->docker_compose_location;+ $initialBaseDirectory = $restoreBaseDirectory ?? $this->base_directory;if ($isInit && $this->docker_compose_raw) {return;}@@ -1580,6 +1582,7 @@ class Application extends BaseModelthrow new \RuntimeException($e->getMessage());} finally {$this->docker_compose_location = $initialDockerComposeLocation;+ $this->base_directory = $initialBaseDirectory;$this->save();$commands = collect(["rm -rf /tmp/{$uuid}",