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
feat: debuggable executeNow commands
Andras Bacsai14919980c2e1
diff --git a/app/Http/Livewire/DeployApplication.php b/app/Http/Livewire/DeployApplication.phpindex 8533d33573..a18d85f6ba 100644--- a/app/Http/Livewire/DeployApplication.php+++ b/app/Http/Livewire/DeployApplication.php@@ -53,6 +53,14 @@ class DeployApplication extends Component$this->application->status = 'stopped';$this->application->save();}+ public function kill()+ {+ runRemoteCommandSync($this->destination->server, ["docker rm -f {$this->application_uuid}"]);+ if ($this->application->status != 'exited') {+ $this->application->status = 'exited';+ $this->application->save();+ }+ }public function pollingStatus(){diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.phpindex e22a55aab2..b66d9fd782 100644--- a/app/Jobs/ContainerStatusJob.php+++ b/app/Jobs/ContainerStatusJob.php@@ -19,6 +19,14 @@ class ContainerStatusJob implements ShouldQueuepublic string|null $container_id = null,) {}+ public function handle(): void+ {+ if ($this->container_id) {+ $this->checkContainerStatus();+ } else {+ $this->checkAllServers();+ }+ }protected function checkAllServers(){try {@@ -69,12 +77,4 @@ class ContainerStatusJob implements ShouldQueueLog::error($e->getMessage());}}- public function handle(): void- {- if ($this->container_id) {- $this->checkContainerStatus();- } else {- $this->checkAllServers();- }- }}diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.phpindex b648572223..86a998d3ba 100644--- a/app/Jobs/DeployApplicationJob.php+++ b/app/Jobs/DeployApplicationJob.php@@ -97,7 +97,7 @@ class DeployApplicationJob implements ShouldQueueif ($this->activity->properties->get('stopped_container_check') == 0) {$this->executeNow([- "echo 'Container {$this->application->uuid} was stopped, starting it...'"+ "echo -n 'Container {$this->application->uuid} was stopped, starting it...'"]);$this->executeNow(["docker start {$this->application->uuid}"@@ -144,30 +144,39 @@ class DeployApplicationJob implements ShouldQueue$this->executeNow(["echo -n 'Generating nixpacks configuration... '",+ ]);+ $this->executeNow([$this->nixpacks_build_cmd(),$this->execute_in_builder("cp {$this->workdir}/.nixpacks/Dockerfile {$this->workdir}/Dockerfile"),$this->execute_in_builder("rm -f {$this->workdir}/.nixpacks/Dockerfile"),+ ], isDebuggable: true);++ $this->executeNow(["echo 'Done.'",+ "echo -n 'Building image... '",]);+$this->executeNow([- "echo -n 'Building image... '",$this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile --build-arg SOURCE_COMMIT={$this->git_commit} --progress plain -t {$this->application->uuid}:{$this->git_commit} {$this->workdir}"),- "echo 'Done.'",- ]);+ ], isDebuggable: true);+$this->executeNow([- "echo -n 'Removing old container... '",+ "echo 'Done.'",+ "echo -n 'Removing old instance... '",$this->execute_in_builder("docker rm -f {$this->application->uuid} >/dev/null 2>&1"),"echo 'Done.'",+ "echo -n 'Starting your application... '",]);$this->executeNow([- "echo -n 'Starting new container... '",$this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d >/dev/null"),+ ], isDebuggable: true);++ $this->executeNow(["echo 'Done. 🎉'","docker stop -t 0 {$this->deployment_uuid} >/dev/null"], setStatus: true);}-dispatch(new ContainerStatusJob($this->application_uuid));// Saving docker-compose.yml@@ -305,9 +314,10 @@ class DeployApplicationJob implements ShouldQueuereturn $labels;}- private function executeNow(array|Collection $command, string $propertyName = null, bool $hideFromOutput = false, $setStatus = false)+ private function executeNow(array|Collection $command, string $propertyName = null, bool $hideFromOutput = false, $setStatus = false, bool $isDebuggable = false){static::$batch_counter++;+if ($command instanceof Collection) {$commandText = $command->implode("\n");} else {@@ -318,7 +328,9 @@ class DeployApplicationJob implements ShouldQueue'command' => $commandText,]);$this->activity->save();-+ if ($isDebuggable && !$this->application->settings->is_debug) {+ $hideFromOutput = true;+ }$remoteProcess = resolve(RunRemoteProcess::class, ['activity' => $this->activity,'hideFromOutput' => $hideFromOutput,diff --git a/database/seeders/ApplicationSettingsSeeder.php b/database/seeders/ApplicationSettingsSeeder.phpindex fceb329548..1b6068ad58 100644--- a/database/seeders/ApplicationSettingsSeeder.php+++ b/database/seeders/ApplicationSettingsSeeder.php@@ -17,10 +17,8 @@ class ApplicationSettingsSeeder extends Seeder*/public function run(): void{- // $application_1 = Application::find(1);- // ApplicationSetting::create([- // 'id' => 1,- // 'application_id' => $application_1->id,- // ]);+ $application_1 = Application::find(1)->load(['settings']);+ $application_1->settings->is_debug = false;+ $application_1->settings->save();}}diff --git a/resources/views/livewire/deploy-application.blade.php b/resources/views/livewire/deploy-application.blade.phpindex ecaf3119ce..f10497bc13 100644--- a/resources/views/livewire/deploy-application.blade.php+++ b/resources/views/livewire/deploy-application.blade.php@@ -4,5 +4,6 @@@else<button wire:click='start'>Start</button>@endif+ <button wire:click='kill'>Kill</button><span wire:poll='pollingStatus'>status: {{ $application->status }}</span></div>