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
lots of UI fixes
Andras Bacsai8b128c1bbe78
diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/StartProxy.phpsimilarity index 99%rename from app/Actions/Proxy/InstallProxy.phprename to app/Actions/Proxy/StartProxy.phpindex 1e2369f8a2..2050e2ca16 100644--- a/app/Actions/Proxy/InstallProxy.php+++ b/app/Actions/Proxy/StartProxy.php@@ -8,7 +8,7 @@ use App\Models\Server;use Spatie\Activitylog\Models\Activity;use Illuminate\Support\Str;-class InstallProxy+class StartProxy{public function __invoke(Server $server): Activity{diff --git a/app/Http/Controllers/MagicController.php b/app/Http/Controllers/MagicController.phpindex 66dcf55496..c4f77805a1 100644--- a/app/Http/Controllers/MagicController.php+++ b/app/Http/Controllers/MagicController.php@@ -13,7 +13,7 @@ class MagicController extends Controllerpublic function servers(){return response()->json([- 'servers' => Server::validated()->get()+ 'servers' => Server::isUsable()->get()]);}public function destinations()diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.phpindex e790e35653..5d3c1ebba4 100644--- a/app/Http/Livewire/Server/Proxy.php+++ b/app/Http/Livewire/Server/Proxy.php@@ -27,14 +27,16 @@ class Proxy extends Component}public function switchProxy(){- $this->server->proxy->type = null;+ $this->server->proxy = null;$this->server->save();+ $this->emit('proxyStatusUpdated');}public function setProxy(string $proxy_type){$this->server->proxy->type = $proxy_type;$this->server->proxy->status = 'exited';$this->server->save();+ $this->emit('proxyStatusUpdated');}public function stopProxy(){diff --git a/app/Http/Livewire/Server/Proxy/Deploy.php b/app/Http/Livewire/Server/Proxy/Deploy.phpindex afb7202a44..c1ca4ab578 100644--- a/app/Http/Livewire/Server/Proxy/Deploy.php+++ b/app/Http/Livewire/Server/Proxy/Deploy.php@@ -2,7 +2,7 @@namespace App\Http\Livewire\Server\Proxy;-use App\Actions\Proxy\InstallProxy;+use App\Actions\Proxy\StartProxy;use App\Models\Server;use Livewire\Component;use Str;@@ -24,7 +24,7 @@ class Deploy extends Component) {$this->saveConfiguration($this->server);}- $activity = resolve(InstallProxy::class)($this->server);+ $activity = resolve(StartProxy::class)($this->server);$this->emit('newMonitorActivity', $activity->id);}public function stop()diff --git a/app/Http/Livewire/Settings/Configuration.php b/app/Http/Livewire/Settings/Configuration.phpindex a5c9ad335a..98371d136f 100644--- a/app/Http/Livewire/Settings/Configuration.php+++ b/app/Http/Livewire/Settings/Configuration.php@@ -2,8 +2,7 @@namespace App\Http\Livewire\Settings;-use App\Actions\Proxy\InstallProxy;-use App\Jobs\ProxyCheckJob;+use App\Jobs\ProxyStartJob;use App\Models\InstanceSettings as ModelsInstanceSettings;use App\Models\Server;use Livewire\Component;@@ -108,7 +107,7 @@ class Configuration extends Component];}$this->save_configuration_to_disk($traefik_dynamic_conf, $file);- dispatch(new ProxyCheckJob($this->server));+ dispatch(new ProxyStartJob($this->server));}}private function save_configuration_to_disk(array $traefik_dynamic_conf, string $file)diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex d9e0806481..a800d7c2e6 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -117,7 +117,7 @@ class ApplicationDeploymentJob implements ShouldQueue} else {$this->deploy();}- if ($this->application->fqdn) dispatch(new ProxyCheckJob($this->server));+ if ($this->application->fqdn) dispatch(new ProxyStartJob($this->server));$this->next(ApplicationDeploymentStatus::FINISHED->value);} catch (\Exception $e) {ray($e);diff --git a/app/Jobs/ProxyCheckJob.php b/app/Jobs/ProxyCheckJob.phpindex dbe785d965..ab04d3d070 100755--- a/app/Jobs/ProxyCheckJob.php+++ b/app/Jobs/ProxyCheckJob.php@@ -2,7 +2,7 @@namespace App\Jobs;-use App\Actions\Proxy\InstallProxy;+use App\Actions\Proxy\StartProxy;use App\Enums\ProxyTypes;use App\Models\Server;use Illuminate\Bus\Queueable;@@ -15,30 +15,20 @@ class ProxyCheckJob implements ShouldQueue{use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;- public function __construct(protected Server|null $server = null)+ public function __construct(){}public function handle(){try {$container_name = 'coolify-proxy';- if ($this->server) {- ray('Checking proxy for server: ' . $this->server->name);- $status = get_container_status(server: $this->server, container_id: $container_name);+ $servers = Server::isUsable()->whereNotNull('proxy')->get();+ foreach ($servers as $server) {+ $status = get_container_status(server: $server, container_id: $container_name);if ($status === 'running') {- return;- }- resolve(InstallProxy::class)($this->server);- } else {- $servers = Server::whereRelation('settings', 'is_usable', true)->get();-- foreach ($servers as $server) {- $status = get_container_status(server: $server, container_id: $container_name);- if ($status === 'running') {- continue;- }- resolve(InstallProxy::class)($server);+ continue;}+ resolve(StartProxy::class)($server);}} catch (\Throwable $th) {ray($th->getMessage());diff --git a/app/Jobs/ProxyStartJob.php b/app/Jobs/ProxyStartJob.phpnew file mode 100755index 0000000000..074d216645--- /dev/null+++ b/app/Jobs/ProxyStartJob.php@@ -0,0 +1,35 @@+<?php++namespace App\Jobs;++use App\Actions\Proxy\StartProxy;+use App\Models\Server;+use Illuminate\Bus\Queueable;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Foundation\Bus\Dispatchable;+use Illuminate\Queue\InteractsWithQueue;+use Illuminate\Queue\SerializesModels;++class ProxyStartJob implements ShouldQueue+{+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;++ public function __construct(protected Server $server)+ {+ }+ public function handle()+ {+ try {+ $container_name = 'coolify-proxy';+ ray('Starting proxy for server: ' . $this->server->name);+ $status = get_container_status(server: $this->server, container_id: $container_name);+ if ($status === 'running') {+ return;+ }+ resolve(StartProxy::class)($this->server);+ } catch (\Throwable $th) {+ ray($th->getMessage());+ //throw $th;+ }+ }+}diff --git a/app/Models/Server.php b/app/Models/Server.phpindex 0d21e80b02..31e2d1e5ce 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -94,10 +94,14 @@ class Server extends BaseModelreturn Server::whereTeamId(session('currentTeam')->id)->with('settings')->select($selectArray->all())->orderBy('name');}- static public function validated()+ static public function isReachable(){return Server::ownedByCurrentTeam()->whereRelation('settings', 'is_reachable', true);}+ static public function isUsable()+ {+ return Server::ownedByCurrentTeam()->whereRelation('settings', 'is_reachable', true)->whereRelation('settings', 'is_usable', true);+ }static public function destinationsByServer(string $server_id){@@ -106,4 +110,4 @@ class Server extends BaseModel$swarmDocker = collect($server->swarmDockers->all());return $standaloneDocker->concat($swarmDocker);}-}\ No newline at end of file+}diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.phpindex e43092b129..82ab2552b8 100644--- a/database/seeders/ServerSeeder.php+++ b/database/seeders/ServerSeeder.php@@ -2,7 +2,6 @@namespace Database\Seeders;-use App\Actions\Proxy\InstallProxy;use App\Data\ServerMetadata;use App\Enums\ProxyStatus;use App\Enums\ProxyTypes;diff --git a/database/seeders/ServerSettingSeeder.php b/database/seeders/ServerSettingSeeder.phpindex f2d8c9b496..fe366ba77a 100644--- a/database/seeders/ServerSettingSeeder.php+++ b/database/seeders/ServerSettingSeeder.php@@ -16,12 +16,14 @@ class ServerSettingSeeder extends Seeder$server_2 = Server::find(0)->load(['settings']);$server_2->settings->wildcard_domain = 'http://127.0.0.1.sslip.io';$server_2->settings->is_build_server = true;+ $server_2->settings->is_usable = true;$server_2->settings->is_reachable = true;$server_2->settings->save();$server_3 = Server::find(1)->load(['settings']);$server_3->settings->is_part_of_swarm = false;+ $server_2->settings->is_usable = false;$server_3->settings->is_reachable = false;$server_3->settings->save();}-}\ No newline at end of file+}diff --git a/resources/views/components/server/navbar.blade.php b/resources/views/components/server/navbar.blade.phpindex 5fe9b07596..dcfd76dbb3 100644--- a/resources/views/components/server/navbar.blade.php+++ b/resources/views/components/server/navbar.blade.php@@ -26,11 +26,9 @@]) }}"><button>Destinations</button></a>- @if ($server->settings->is_reachable)- @if (request()->routeIs('server.proxy'))- <div class="flex-1"></div>- <livewire:server.proxy.deploy :server="$server" />- @endif+ @if (request()->routeIs('server.proxy'))+ <div class="flex-1"></div>+ <livewire:server.proxy.deploy :server="$server" />@endif</nav></div>diff --git a/resources/views/livewire/destination/show.blade.php b/resources/views/livewire/destination/show.blade.phpindex a59c05f2b4..f39b2a3a89 100644--- a/resources/views/livewire/destination/show.blade.php+++ b/resources/views/livewire/destination/show.blade.php@@ -1,32 +1,36 @@<div>- <div class="flex items-end gap-2">- <h2>Destinations</h2>- <a href="{{ route('destination.new', ['server_id' => $server->id]) }}">- <x-forms.button>Add a new destination</x-forms.button>- </a>- <x-forms.button wire:click='scan'>Scan destinations on the server</x-forms.button>- </div>- <div class="pt-2 pb-6 ">Destinations are used to segregate resources by network.</div>- <div class="flex gap-2 ">- Available for using:- @forelse ($server->standaloneDockers as $docker)- <a href="{{ route('destination.show', ['destination_uuid' => data_get($docker, 'uuid')]) }}">- <button class="text-white btn-link">{{ data_get($docker, 'network') }} </button>+ @if ($server->settings->is_usable)+ <div class="flex items-end gap-2">+ <h2>Destinations</h2>+ <a href="{{ route('destination.new', ['server_id' => $server->id]) }}">+ <x-forms.button>Add a new destination</x-forms.button></a>- @empty- <div class="">N/A</div>- @endforelse- </div>- <div class="grid gap-2 pt-2">- @if (count($networks) > 0)- <h4>Found Destinations</h4>- @endif- @foreach ($networks as $network)- <a- href="{{ route('destination.new', ['server_id' => $server->id, 'network_name' => data_get($network, 'Name')]) }}">- <x-forms.button>Add<span class="text-warning">{{ data_get($network, 'Name') }}</span>- </x-forms.button>- </a>- @endforeach- </div>+ <x-forms.button wire:click='scan'>Scan destinations on the server</x-forms.button>+ </div>+ <div class="pt-2 pb-6 ">Destinations are used to segregate resources by network.</div>+ <div class="flex gap-2 ">+ Available for using:+ @forelse ($server->standaloneDockers as $docker)+ <a href="{{ route('destination.show', ['destination_uuid' => data_get($docker, 'uuid')]) }}">+ <button class="text-white btn-link">{{ data_get($docker, 'network') }} </button>+ </a>+ @empty+ <div class="">N/A</div>+ @endforelse+ </div>+ <div class="grid gap-2 pt-2">+ @if (count($networks) > 0)+ <h4>Found Destinations</h4>+ @endif+ @foreach ($networks as $network)+ <a+ href="{{ route('destination.new', ['server_id' => $server->id, 'network_name' => data_get($network, 'Name')]) }}">+ <x-forms.button>Add<span class="text-warning">{{ data_get($network, 'Name') }}</span>+ </x-forms.button>+ </a>+ @endforeach+ </div>+ @else+ <div>Server is not validated. Validate first.</div>+ @endif</div>diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.phpindex a312789853..26620ea0fc 100644--- a/resources/views/livewire/server/proxy.blade.php+++ b/resources/views/livewire/server/proxy.blade.php@@ -1,7 +1,7 @@<div x-data="{ stopProxy: false }"><x-naked-modal show="stopProxy" action="stopProxy" title="Stop Proxy"message='This proxy will be stopped. It is not reversible. <br>All resources will be unavailable. <br>Please think again.' />- @if ($server->settings->is_reachable)+ @if ($server->settings->is_usable)@if ($server->proxy->type)<div x-init="$wire.checkProxySettingsInSync">@if ($selectedProxy->value === 'TRAEFIK_V2')@@ -12,9 +12,7 @@@if ($server->proxy->status === 'exited')<x-forms.button wire:click.prevent="switchProxy">Switch Proxy</x-forms.button>@endif- @if ($server->settings->is_reachable)- <livewire:server.proxy.status :server="$server" />- @endif+ <livewire:server.proxy.status :server="$server" /></div><div class="pt-3 pb-4 ">Traefik v2</div>@@ -66,6 +64,6 @@</div>@endif@else- <div class="">Server is not validated. Validate first.</div>+ <div>Server is not validated. Validate first.</div>@endif</div>diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.phpindex b08d90948d..01abbc38cb 100644--- a/resources/views/livewire/server/proxy/deploy.blade.php+++ b/resources/views/livewire/server/proxy/deploy.blade.php@@ -1,76 +1,79 @@<div>- @if ($server->proxy->status === 'running')- <div class="flex gap-4">- <div class="group">- <label tabindex="0" class="flex items-center gap-2 cursor-pointer hover:text-white"> Links- <x-chevron-down />- </label>- <div class="absolute hidden group-hover:block ">- <ul tabindex="0"- class="relative text-xs text-white normal-case rounded -ml-28 min-w-max menu bg-coolgray-200">- <li>- @if ($server->name === 'localhost')- <a target="_blank"- class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"- href="{{ base_ip() }}:8080">- Traefik Dashboard- <x-external-link />- </a>- @else- <a target="_blank"- class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"- href="http://{{ $server->ip }}:8080">- Traefik Dashboard- <x-external-link />- </a>- @endif- </li>- </ul>+ @if (data_get($server, 'proxy.type'))+ @if (data_get($server, 'proxy.status') === 'running')+ <div class="flex gap-4">+ <div class="group">+ <label tabindex="0" class="flex items-center gap-2 cursor-pointer hover:text-white"> Links+ <x-chevron-down />+ </label>+ <div class="absolute hidden group-hover:block ">+ <ul tabindex="0"+ class="relative text-xs text-white normal-case rounded -ml-28 min-w-max menu bg-coolgray-200">+ <li>+ @if ($server->name === 'localhost')+ <a target="_blank"+ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"+ href="{{ base_ip() }}:8080">+ Traefik Dashboard+ <x-external-link />+ </a>+ @else+ <a target="_blank"+ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"+ href="http://{{ $server->ip }}:8080">+ Traefik Dashboard+ <x-external-link />+ </a>+ @endif+ </li>+ </ul>+ </div></div>- </div>- <div class="group">- <label tabindex="0" class="flex items-center gap-2 cursor-pointer hover:text-white"> Actions- <x-chevron-down />- </label>- <div class="absolute hidden group-hover:block ">- <ul tabindex="0"- class="relative text-xs text-white normal-case rounded min-w-max menu bg-coolgray-200 -ml-14">- <li>- <div class="rounded-none hover:bg-coollabs hover:text-white" wire:click='deploy'><svg- xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"- stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"- stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4" />- <path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4" />- <path d="M12 9l0 3" />- <path d="M12 15l.01 0" />- </svg>Restart</div>- </li>- <li>- <div class="rounded-none hover:bg-red-500 hover:text-white" wire:click='stop'><svg- xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"- stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"- stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5" />- <path d="M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5" />- <path d="M14 5.5a1.5 1.5 0 0 1 3 0v6.5" />- <path- d="M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47" />- </svg>Stop</div>- </li>- </ul>+ <div class="group">+ <label tabindex="0" class="flex items-center gap-2 cursor-pointer hover:text-white"> Actions+ <x-chevron-down />+ </label>+ <div class="absolute hidden group-hover:block ">+ <ul tabindex="0"+ class="relative text-xs text-white normal-case rounded min-w-max menu bg-coolgray-200 -ml-14">+ <li>+ <div class="rounded-none hover:bg-coollabs hover:text-white" wire:click='deploy'><svg+ xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4" />+ <path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4" />+ <path d="M12 9l0 3" />+ <path d="M12 15l.01 0" />+ </svg>Restart</div>+ </li>+ <li>+ <div class="rounded-none hover:bg-red-500 hover:text-white" wire:click='stop'><svg+ xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5" />+ <path d="M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5" />+ <path d="M14 5.5a1.5 1.5 0 0 1 3 0v6.5" />+ <path+ d="M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47" />+ </svg>Stop</div>+ </li>+ </ul>+ </div></div></div>- </div>- @else- <button wire:click='deploy' class="flex items-center gap-2 cursor-pointer hover:text-white">- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-warning" viewBox="0 0 24 24" stroke-width="1.5"- stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M7 4v16l13 -8z" />- </svg>Start Proxy- </button>+ @else+ <button wire:click='deploy' class="flex items-center gap-2 cursor-pointer hover:text-white">+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-warning" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M7 4v16l13 -8z" />+ </svg>Start Proxy+ </button>+ @endif@endif</div>diff --git a/resources/views/server/all.blade.php b/resources/views/server/all.blade.phpindex b08b2c845f..c7ee37a2a9 100644--- a/resources/views/server/all.blade.php+++ b/resources/views/server/all.blade.php@@ -11,13 +11,22 @@<div class="flex flex-col mx-6"><div class=" group-hover:text-white">{{ $server->name }}- @if (!$server->settings->is_reachable)- <span class="text-xs text-error">not validated yet</span>- @endif+</div><div class="text-xs group-hover:text-white"href="{{ route('server.show', ['server_uuid' => data_get($server, 'uuid')]) }}">{{ $server->description }}</div>+ <div class="flex gap-1 text-xs text-error">+ @if (!$server->settings->is_reachable)+ <span>Not reachable</span>+ @endif+ @if (!$server->settings->is_reachable && !$server->settings->is_usable)+ &+ @endif+ @if (!$server->settings->is_usable)+ <span>Not usable by Coolify</span>+ @endif+ </div></div><div class="flex-1"></div></div>diff --git a/routes/web.php b/routes/web.phpindex b72fc889d5..10e15d77d4 100644--- a/routes/web.php+++ b/routes/web.php@@ -93,7 +93,7 @@ Route::middleware(['auth'])->group(function () {Route::get('/team/new', fn () => view('team.create'))->name('team.create');Route::get('/team/notifications', fn () => view('team.notifications'))->name('team.notifications');Route::get('/team/members', [Controller::class, 'members'])->name('team.members');- Route::get('/command-center', fn () => view('command-center', ['servers' => Server::validated()->get()]))->name('command-center');+ Route::get('/command-center', fn () => view('command-center', ['servers' => Server::isReachable()->get()]))->name('command-center');Route::get('/invitations/{uuid}', [Controller::class, 'acceptInvitation'])->name('team.invitation.accept');Route::get('/invitations/{uuid}/revoke', [Controller::class, 'revokeInvitation'])->name('team.invitation.revoke');});@@ -156,7 +156,7 @@ Route::middleware(['auth'])->group(function () {]);})->name('destination.all');Route::get('/destination/new', function () {- $servers = Server::validated()->get();+ $servers = Server::isUsable()->get();$pre_selected_server_uuid = data_get(request()->query(), 'server');if ($pre_selected_server_uuid) {$server = $servers->firstWhere('uuid', $pre_selected_server_uuid);