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
code improvements
Andras Bacsaib37082662496
diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.phpnew file mode 100644index 0000000000..45ac000c94--- /dev/null+++ b/app/Console/Commands/Init.php@@ -0,0 +1,36 @@+<?php++namespace App\Console\Commands;++use App\Models\ApplicationDeploymentQueue;+use Illuminate\Console\Command;++class Init extends Command+{+ /**+ * The name and signature of the console command.+ *+ * @var string+ */+ protected $signature = 'app:init';++ /**+ * The console command description.+ *+ * @var string+ */+ protected $description = 'Cleanup instance related stuffs';++ /**+ * Execute the console command.+ */+ public function handle()+ {+ try {+ $halted_deployments = ApplicationDeploymentQueue::where('status', '==', 'in_progress')->get();+ ray($halted_deployments);+ } catch (\Exception $e) {+ echo "Error: {$e->getMessage()}\n";+ }+ }+}diff --git a/app/Console/Kernel.php b/app/Console/Kernel.phpindex d8d5dabd52..3b320366ff 100644--- a/app/Console/Kernel.php+++ b/app/Console/Kernel.php@@ -19,6 +19,7 @@ class Kernel extends ConsoleKernel} else {$schedule->command('horizon:snapshot')->everyFiveMinutes();$schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();+ $schedule->job(new InstanceProxyCheckJob)->everyFiveMinutes();$schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes();}}diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.phpindex 3dbd6115d3..a1b3038024 100644--- a/app/Http/Controllers/ApplicationController.php+++ b/app/Http/Controllers/ApplicationController.php@@ -41,7 +41,8 @@ class ApplicationController extends Controllerif (!$application) {return redirect()->route('dashboard');}- return view('project.application.deployments', ['application' => $application]);+ ['deployments' => $deployments, 'count' => $count] = $application->deployments(0, 8);+ return view('project.application.deployments', ['application' => $application, 'deployments' => $deployments, 'deployments_count' => $count]);}public function deployment()diff --git a/app/Http/Livewire/Project/Application/Deployments.php b/app/Http/Livewire/Project/Application/Deployments.phpindex 9dd6e96316..16b40895b0 100644--- a/app/Http/Livewire/Project/Application/Deployments.php+++ b/app/Http/Livewire/Project/Application/Deployments.php@@ -7,7 +7,7 @@ use Livewire\Component;class Deployments extends Component{- public int $application_id;+ public Application $application;public $deployments = [];public int $deployments_count = 0;public string $current_url;@@ -18,6 +18,17 @@ class Deployments extends Componentpublic function mount(){$this->current_url = url()->current();+ $this->show_more();+ }+ private function show_more()+ {+ if (count($this->deployments) !== 0) {+ $this->show_next = true;+ if (count($this->deployments) < $this->default_take) {+ $this->show_next = false;+ }+ return;+ }}public function reload_deployments(){@@ -28,17 +39,11 @@ class Deployments extends Componentif ($take) {$this->skip = $this->skip + $take;}-$take = $this->default_take;- ['deployments' => $deployments, 'count' => $count] = Application::find($this->application_id)->deployments($this->skip, $take);++ ['deployments' => $deployments, 'count' => $count] = $this->application->deployments($this->skip, $take);$this->deployments = $deployments;$this->deployments_count = $count;- if (count($this->deployments) !== 0) {- $this->show_next = true;- if (count($this->deployments) < $take) {- $this->show_next = false;- }- return;- }+ $this->show_more();}}diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 416340565f..87fca814c5 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -309,6 +309,8 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory}$this->application_deployment_queue->update(['status' => $status,]);+ ray($this->application_deployment_queue)->purple();+ ray($this->activity)->purple();$this->activity->properties = $this->activity->properties->merge(['status' => $status,]);diff --git a/app/Jobs/InstanceProxyCheckJob.php b/app/Jobs/InstanceProxyCheckJob.phpindex 4387cd3188..6d90f1be3e 100755--- a/app/Jobs/InstanceProxyCheckJob.php+++ b/app/Jobs/InstanceProxyCheckJob.php@@ -29,7 +29,7 @@ class InstanceProxyCheckJob implements ShouldQueue{try {$container_name = 'coolify-proxy';- $servers = Server::whereRelation('settings', 'is_reachable', true)->where('proxy->type', ProxyTypes::TRAEFIK_V2)->get();+ $servers = Server::whereRelation('settings', 'is_usable', true)->where('proxy->type', ProxyTypes::TRAEFIK_V2)->get();foreach ($servers as $server) {$status = get_container_status(server: $server, container_id: $container_name);diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-seeder/dependencies.d/db-migration b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/dependencies.d/init-seedersimilarity index 100%rename from docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-seeder/dependencies.d/db-migrationrename to docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/dependencies.d/init-seederdiff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/type b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/typenew file mode 100644index 0000000000..bdd22a1850--- /dev/null+++ b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/type@@ -0,0 +1 @@+oneshotdiff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/upnew file mode 100644index 0000000000..09595f7081--- /dev/null+++ b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up@@ -0,0 +1,2 @@+#!/command/execlineb -P+php /var/www/html/artisan app:initdiff --git a/resources/views/livewire/project/application/deployments.blade.php b/resources/views/livewire/project/application/deployments.blade.phpindex 1385025afd..0bca78a43c 100644--- a/resources/views/livewire/project/application/deployments.blade.php+++ b/resources/views/livewire/project/application/deployments.blade.php@@ -1,5 +1,4 @@- <div class="flex flex-col gap-2" wire:init='load_deployments'- @if ($skip == 0) wire:poll.5000ms='reload_deployments' @endif>+ <div class="flex flex-col gap-2" @if ($skip == 0) wire:poll.5000ms='reload_deployments' @endif><h2 class="pt-4">Deployments <span class="text-xs">({{ $deployments_count }})</span></h2>@if ($show_next)<x-forms.button wire:click="load_deployments({{ $default_take }})">Show Morediff --git a/resources/views/project/application/deployments.blade.php b/resources/views/project/application/deployments.blade.phpindex 1f68340b4f..b4fcd8982a 100644--- a/resources/views/project/application/deployments.blade.php+++ b/resources/views/project/application/deployments.blade.php@@ -1,5 +1,5 @@<x-layout><h1>Deployments</h1><livewire:application.heading :application="$application" />- <livewire:project.application.deployments :application_id="$application->id" />+ <livewire:project.application.deployments :application="$application" :deployments="$deployments" :deployments_count="$deployments_count" /></x-layout>