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: proxy status fix: start proxy in case any dns set somewhere
Andras Bacsaie9ba295a1e08
diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.phpindex c967a4687b..1e2369f8a2 100644--- a/app/Actions/Proxy/InstallProxy.php+++ b/app/Actions/Proxy/InstallProxy.php@@ -12,6 +12,7 @@ class InstallProxy{public function __invoke(Server $server): Activity{+ // TODO: check for other proxiesif (is_null(data_get($server, 'proxy.type'))) {$server->proxy->type = ProxyTypes::TRAEFIK_V2->value;$server->proxy->status = ProxyStatus::EXITED->value;diff --git a/app/Http/Livewire/Project/Application/Status.php b/app/Http/Livewire/Project/Application/Status.phpdeleted file mode 100644index 107cce4ae0..0000000000--- a/app/Http/Livewire/Project/Application/Status.php+++ /dev/null@@ -1,17 +0,0 @@-<?php--namespace App\Http\Livewire\Project\Application;--use App\Models\Application;-use Livewire\Component;--class Status extends Component-{- public Application $application;-- public function applicationStatusChanged()- {- $this->application->refresh();- $this->emit('applicationStatusChanged');- }-}diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.phpindex c7c056665a..eeb0df413e 100644--- a/app/Http/Livewire/Server/Form.php+++ b/app/Http/Livewire/Server/Form.php@@ -63,7 +63,7 @@ class Form extends Component} else {$this->server->settings->is_usable = true;$this->server->settings->save();- $this->emit('serverValidated');+ $this->emit('proxyStatusUpdated');}} catch (\Exception $e) {$this->server->settings->is_reachable = false;diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.phpindex 95e3e7e769..e790e35653 100644--- a/app/Http/Livewire/Server/Proxy.php+++ b/app/Http/Livewire/Server/Proxy.php@@ -3,7 +3,6 @@namespace App\Http\Livewire\Server;use App\Actions\Proxy\CheckProxySettingsInSync;-use App\Actions\Proxy\InstallProxy;use App\Enums\ProxyTypes;use Illuminate\Support\Str;use App\Models\Server;@@ -17,12 +16,12 @@ class Proxy extends Componentpublic $proxy_settings = null;public string|null $redirect_url = null;- protected $listeners = ['serverValidated', 'saveConfiguration'];+ protected $listeners = ['proxyStatusUpdated', 'saveConfiguration'];public function mount(){$this->redirect_url = $this->server->proxy->redirect_url;}- public function serverValidated()+ public function proxyStatusUpdated(){$this->server->refresh();}@@ -44,7 +43,7 @@ class Proxy extends Component], $this->server);$this->server->proxy->status = 'exited';$this->server->save();- $this->server->refresh();+ $this->emit('proxyStatusUpdated');}public function saveConfiguration(){diff --git a/app/Http/Livewire/Server/Proxy/Deploy.php b/app/Http/Livewire/Server/Proxy/Deploy.phpindex aa12886f26..afb7202a44 100644--- a/app/Http/Livewire/Server/Proxy/Deploy.php+++ b/app/Http/Livewire/Server/Proxy/Deploy.php@@ -11,7 +11,7 @@ class Deploy extends Component{public Server $server;public $proxy_settings = null;- protected $listeners = ['proxyStatusUpdated', 'serverValidated' => 'proxyStatusUpdated'];+ protected $listeners = ['proxyStatusUpdated'];public function proxyStatusUpdated(){$this->server->refresh();diff --git a/app/Http/Livewire/Server/Proxy/Status.php b/app/Http/Livewire/Server/Proxy/Status.phpindex 8a7725f85f..e4d18e4a25 100644--- a/app/Http/Livewire/Server/Proxy/Status.php+++ b/app/Http/Livewire/Server/Proxy/Status.php@@ -9,7 +9,7 @@ use Livewire\Component;class Status extends Component{public Server $server;- protected $listeners = ['proxyStatusUpdated', 'serverValidated' => 'proxyStatusUpdated'];+ protected $listeners = ['proxyStatusUpdated'];public function proxyStatusUpdated(){$this->server->refresh();@@ -17,7 +17,7 @@ class Status extends Componentpublic function proxyStatus(){try {- dispatch(new ProxyContainerStatusJob(+ dispatch_sync(new ProxyContainerStatusJob(server: $this->server));$this->emit('proxyStatusUpdated');diff --git a/app/Http/Livewire/Settings/Configuration.php b/app/Http/Livewire/Settings/Configuration.phpindex 889e720096..a5c9ad335a 100644--- a/app/Http/Livewire/Settings/Configuration.php+++ b/app/Http/Livewire/Settings/Configuration.php@@ -2,10 +2,10 @@namespace App\Http\Livewire\Settings;+use App\Actions\Proxy\InstallProxy;use App\Jobs\ProxyCheckJob;use App\Models\InstanceSettings as ModelsInstanceSettings;use App\Models\Server;-use Illuminate\Support\Facades\Http;use Livewire\Component;use Spatie\Url\Url;use Symfony\Component\Yaml\Yaml;@@ -108,6 +108,7 @@ class Configuration extends Component];}$this->save_configuration_to_disk($traefik_dynamic_conf, $file);+ dispatch(new ProxyCheckJob($this->server));}}private function save_configuration_to_disk(array $traefik_dynamic_conf, string $file)@@ -137,12 +138,8 @@ class Configuration extends Component}$this->validate();$this->settings->save();-$this->server = Server::findOrFail(0);$this->setup_instance_fqdn();- if ($this->settings->fqdn) {- dispatch(new ProxyCheckJob());- }$this->emit('success', 'Instance settings updated successfully!');}}diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 7289f08a32..d9e0806481 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -107,7 +107,7 @@ class ApplicationDeploymentJob implements ShouldQueuepublic function handle(): void{- ray()->measure();+ // ray()->measure();$this->application_deployment_queue->update(['status' => ApplicationDeploymentStatus::IN_PROGRESS->value,]);@@ -117,6 +117,7 @@ class ApplicationDeploymentJob implements ShouldQueue} else {$this->deploy();}+ if ($this->application->fqdn) dispatch(new ProxyCheckJob($this->server));$this->next(ApplicationDeploymentStatus::FINISHED->value);} catch (\Exception $e) {ray($e);@@ -131,7 +132,7 @@ class ApplicationDeploymentJob implements ShouldQueue"hidden" => true,]);- ray()->measure();+ // ray()->measure();}}public function failed(Throwable $exception): void@@ -647,4 +648,4 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"););$this->commit = $this->saved_outputs->get('git_commit_sha');}-}\ No newline at end of file+}diff --git a/app/Jobs/ProxyCheckJob.php b/app/Jobs/ProxyCheckJob.phpindex bdc38b875f..f73e23b87d 100755--- a/app/Jobs/ProxyCheckJob.php+++ b/app/Jobs/ProxyCheckJob.php@@ -15,30 +15,33 @@ class ProxyCheckJob implements ShouldQueue{use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;- /**- * Create a new job instance.- */- public function __construct()+ public function __construct(protected Server|null $server){}-- /**- * Execute the job.- */public function handle(){try {$container_name = 'coolify-proxy';- $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);+ if ($this->server) {+ ray('Checking proxy for server: ' . $this->server->name);+ $status = get_container_status(server: $this->server, container_id: $container_name);if ($status === 'running') {- continue;+ 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);}- resolve(InstallProxy::class)($server);}} catch (\Throwable $th) {+ ray($th->getMessage());//throw $th;}}diff --git a/app/Jobs/ProxyContainerStatusJob.php b/app/Jobs/ProxyContainerStatusJob.phpindex 7c4b15ca54..02cd37568e 100644--- a/app/Jobs/ProxyContainerStatusJob.php+++ b/app/Jobs/ProxyContainerStatusJob.php@@ -49,7 +49,10 @@ class ProxyContainerStatusJob implements ShouldQueue, ShouldBeUnique$this->server->save();}} catch (\Exception $e) {- ray($e->getMessage());+ if ($e->getCode() === 1) {+ $this->server->proxy->status = 'exited';+ $this->server->save();+ }}}}diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.phpindex fadd192550..cb718d8aa8 100644--- a/bootstrap/helpers/remoteProcess.php+++ b/bootstrap/helpers/remoteProcess.php@@ -114,7 +114,7 @@ function instant_remote_process(array $command, Server $server, $throwError = trif (!$throwError) {return null;}- throw new \RuntimeException($process->errorOutput());+ throw new \RuntimeException($process->errorOutput(), $exitCode);}return $output;}diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.phpindex 927cee11c8..e43092b129 100644--- a/database/seeders/ServerSeeder.php+++ b/database/seeders/ServerSeeder.php@@ -25,10 +25,10 @@ class ServerSeeder extends Seeder'ip' => "coolify-testing-host",'team_id' => $root_team->id,'private_key_id' => $private_key_1->id,- 'proxy' => ServerMetadata::from([- 'type' => ProxyTypes::TRAEFIK_V2->value,- 'status' => ProxyStatus::EXITED->value- ]),+ // 'proxy' => ServerMetadata::from([+ // 'type' => ProxyTypes::TRAEFIK_V2->value,+ // 'status' => ProxyStatus::EXITED->value+ // ]),]);Server::create(['name' => "testing-local-docker-container-2",@@ -38,4 +38,4 @@ class ServerSeeder extends Seeder'private_key_id' => $private_key_1->id]);}-}\ No newline at end of file+}diff --git a/resources/views/components/server/navbar.blade.php b/resources/views/components/server/navbar.blade.phpindex dcfd76dbb3..5fe9b07596 100644--- a/resources/views/components/server/navbar.blade.php+++ b/resources/views/components/server/navbar.blade.php@@ -26,9 +26,11 @@]) }}"><button>Destinations</button></a>- @if (request()->routeIs('server.proxy'))- <div class="flex-1"></div>- <livewire:server.proxy.deploy :server="$server" />+ @if ($server->settings->is_reachable)+ @if (request()->routeIs('server.proxy'))+ <div class="flex-1"></div>+ <livewire:server.proxy.deploy :server="$server" />+ @endif@endif</nav></div>diff --git a/resources/views/livewire/project/application/status.blade.php b/resources/views/livewire/project/application/status.blade.phpdeleted file mode 100644index 701447df53..0000000000--- a/resources/views/livewire/project/application/status.blade.php+++ /dev/null@@ -1,9 +0,0 @@-<div wire:poll.10000ms='applicationStatusChanged'>- @if ($application->status === 'running')- <x-status.running />- @elseif($application->status === 'restarting')- <x-status.restarting />- @else- <x-status.stopped />- @endif-</div>diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.phpindex bb73798d00..a312789853 100644--- a/resources/views/livewire/server/proxy.blade.php+++ b/resources/views/livewire/server/proxy.blade.php@@ -12,7 +12,9 @@@if ($server->proxy->status === 'exited')<x-forms.button wire:click.prevent="switchProxy">Switch Proxy</x-forms.button>@endif- <livewire:server.proxy.status :server="$server" />+ @if ($server->settings->is_reachable)+ <livewire:server.proxy.status :server="$server" />+ @endif</div><div class="pt-3 pb-4 ">Traefik v2</div>@@ -23,11 +25,11 @@configs.</div>@endif- <x-forms.input placeholder="https://coolify.io" id="redirect_url" label="Default Redirect 404"- helper="All urls that has no service available will be redirected to this domain.<span class='text-helper'>You can set to your main marketing page or your social media link.</span>" />- <div class="container w-full mx-auto">+ <div class="container w-full pb-4 mx-auto"><livewire:activity-monitor :header="true" /></div>+ <x-forms.input placeholder="https://coolify.io" id="redirect_url" label="Default Redirect 404"+ helper="All urls that has no service available will be redirected to this domain.<span class='text-helper'>You can set to your main marketing page or your social media link.</span>" /><div wire:loading wire:target="checkProxySettingsInSync" class="pt-4"><x-loading text="Loading proxy configuration..." /></div>diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.phpindex 03f36a2859..b08d90948d 100644--- a/resources/views/livewire/server/proxy/deploy.blade.php+++ b/resources/views/livewire/server/proxy/deploy.blade.php@@ -1,79 +1,76 @@<div>- @if ($server->settings->is_reachable)- @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>- </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></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>+ </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></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>- @endif+ </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>@endif</div>diff --git a/resources/views/livewire/server/proxy/status.blade.php b/resources/views/livewire/server/proxy/status.blade.phpindex 310d93079d..e27c95ddab 100644--- a/resources/views/livewire/server/proxy/status.blade.php+++ b/resources/views/livewire/server/proxy/status.blade.php@@ -1,13 +1,9 @@-<div>- @if ($server->settings->is_reachable)- <div wire:poll.10000ms="proxyStatus" x-init="$wire.proxyStatus">- @if ($server->proxy->status === 'running')- <x-status.running />- @elseif ($server->proxy->status === 'restarting')- <x-status.restarting />- @else- <x-status.stopped />- @endif- </div>+<div wire:poll.10000ms="proxyStatus" x-init="$wire.proxyStatus">+ @if ($server->proxy->status === 'running')+ <x-status.running />+ @elseif ($server->proxy->status === 'restarting')+ <x-status.restarting />+ @else+ <x-status.stopped />@endif</div>