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 it docker compose has syntax errors
Andras Bacsai7feb788ed381
diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex 66c59cff50..718312d2dd 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -31,7 +31,7 @@ class General extends Componentpublic ?string $initialDockerComposeLocation = null;public ?string $initialDockerComposePrLocation = null;- public $parsedServices = [];+ public null|Collection $parsedServices;public $parsedServiceDomains = [];protected $listeners = [@@ -118,6 +118,10 @@ class General extends Component{try {$this->parsedServices = $this->application->parseCompose();+ if (is_null($this->parsedServices) || empty($this->parsedServices)) {+ $this->dispatch('error', "Failed to parse your docker-compose file. Please check the syntax and try again.");+ return;+ }} catch (\Throwable $e) {$this->dispatch('error', $e->getMessage());}@@ -160,6 +164,10 @@ class General extends Componentreturn;}['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation, 'initialDockerComposePrLocation' => $this->initialDockerComposePrLocation] = $this->application->loadComposeFile($isInit);+ if (is_null($this->parsedServices)) {+ $this->dispatch('error', "Failed to parse your docker-compose file. Please check the syntax and try again.");+ return;+ }$compose = $this->application->parseCompose();$services = data_get($compose, 'services');if ($services) {diff --git a/app/Models/Application.php b/app/Models/Application.phpindex 3d0b92aafa..07c45b83c8 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -879,7 +879,7 @@ class Application extends BaseModelif (!$composeFileContent) {$this->docker_compose_location = $initialDockerComposeLocation;$this->save();- throw new \RuntimeException("Docker Compose file not found at: $workdir$composeFile");+ throw new \RuntimeException("Docker Compose file not found at: $workdir$composeFile<br><br>Check if you used the right extension (.yaml or .yml) in the compose file name.");} else {$this->docker_compose_raw = $composeFileContent;$this->save();diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 7a960066c9..de3d50d1a3 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -1232,13 +1232,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = faltry {$yaml = Yaml::parse($resource->docker_compose_pr_raw);} catch (\Exception $e) {- throw new \Exception($e->getMessage());+ return;}} else {try {$yaml = Yaml::parse($resource->docker_compose_raw);} catch (\Exception $e) {- throw new \Exception($e->getMessage());+ return;}}$server = $resource->destination->server;diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex b9a9711246..df7ba526ce 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -38,7 +38,11 @@</div>@endif@if ($application->build_pack === 'dockercompose')- @if (count($parsedServices) > 0 && !$application->settings->is_raw_compose_deployment_enabled)++ @if (+ !is_null($parsedServices) &&+ count($parsedServices) > 0 &&+ !$application->settings->is_raw_compose_deployment_enabled)<h3 class="pt-6">Domains</h3>@foreach (data_get($parsedServices, 'services') as $serviceName => $service)@if (!isDatabaseImage(data_get($service, 'image')))