From f3845ce30aaf6234c5daef0823ad389236efa0c7 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:55:58 +0200 Subject: [PATCH 1/5] New onboarding error UI and advanced menu --- .../views/livewire/boarding/index.blade.php | 275 +++++++++--------- 1 file changed, 144 insertions(+), 131 deletions(-) diff --git a/resources/views/livewire/boarding/index.blade.php b/resources/views/livewire/boarding/index.blade.php index 2e5fa41c9..cd7ef4c86 100644 --- a/resources/views/livewire/boarding/index.blade.php +++ b/resources/views/livewire/boarding/index.blade.php @@ -1,20 +1,18 @@ @php use App\Enums\ProxyTypes; @endphp Onboarding | Coolify - -
-
- @if ($currentState === 'welcome') + +
+
+ @if ($currentState === 'welcome')

Welcome to Coolify

Let me help you set up the basics.
- Get + Get Started
- @elseif ($currentState === 'explanation') + @elseif ($currentState === 'explanation') Coolify is an all-in-one application to automate tasks on your servers, deploy application with @@ -28,12 +26,15 @@ -

You don't need to manage your servers anymore. +

+ You don't need to manage your servers anymore. Coolify does it for you.

-

All configurations are stored on your servers, so +

+ All configurations are stored on your servers, so everything works without a connection to Coolify (except integrations and automations).

-

You can get notified on your favourite platforms +

+ You can get notified on your favourite platforms (Discord, Telegram, Email, etc.) when something goes wrong, or an action is needed from your side.

@@ -42,70 +43,91 @@
- @elseif ($currentState === 'select-server-type') + @elseif ($currentState === 'select-server-type') - Do you want to deploy your resources to your - or to a ? + Do you want to deploy your resources to your + + or to a + ? - Localhost + Localhost - Remote Server + Remote Server + @if (!$serverReachable) - Localhost is not reachable with the following public key. -

- Please make sure you have the correct public key in your ~/.ssh/authorized_keys file for - user or skip the boarding process and add a new private key manually to Coolify and to the - server. -
- Check this documentation for further - help. - - Check again +
+

Server is not reachable

+

Please check the connection details below and correct them if they are incorrect.

+ +
+ +
+ +

+ Non-root user is experimental: + docs +

+
+
+ +
+

If the connection details are correct, please ensure:

+
    +
  • The correct public key is in your ~/.ssh/authorized_keys file for the specified user
  • +
  • Or skip the boarding process and manually add a new private key to Coolify and the server
  • +
+
+ +

+ For more help, check this documentation. +

+ + + + + Check again +
@endif

Servers are the main building blocks, as they will host your applications, databases, services, called resources. Any CPU intensive process will use the server's CPU where you are deploying your resources.

-

is the server where Coolify is running on. It is not +

+ is the server where Coolify is running on. It is not recommended to use one server for everything.

-

is a server reachable through SSH. It can be hosted +

+ is a server reachable through SSH. It can be hosted at home, or from any cloud provider.

- @elseif ($currentState === 'private-key') + @elseif ($currentState === 'private-key') Do you have your own SSH Private Key? - Yes + Yes - No (create one for me) + No (create one for me) @if (count($privateKeys) > 0) -
- - @foreach ($privateKeys as $privateKey) - - @endforeach - - Use this SSH Key -
+
+ + @foreach ($privateKeys as $privateKey) + + @endforeach + + Use this SSH Key +
@endif
@@ -117,7 +139,7 @@

- @elseif ($currentState === 'select-existing-server') + @elseif ($currentState === 'select-existing-server') There are already servers available for your Team. Do you want to use one of them? @@ -136,8 +158,8 @@
@foreach ($servers as $server) - + @endforeach Use this Server @@ -145,20 +167,18 @@
@if (!$serverReachable) - This server is not reachable with the following public key. -

- Please make sure you have the correct public key in your ~/.ssh/authorized_keys file for - user or skip the boarding process and add a new private key manually to Coolify and to the - server. -
- Check this documentation for further - help. - - Check - again - + This server is not reachable with the following public key. +

+ Please make sure you have the correct public key in your ~/.ssh/authorized_keys file for + user or skip the boarding process and add a new private key manually to Coolify and to the + server. +
+ Check this documentation for further + help. + + Check + again + @endif @@ -169,25 +189,22 @@

- @elseif ($currentState === 'create-private-key') + @elseif ($currentState === 'create-private-key') Please let me know your key details. - - - + + + @if ($privateKeyType === 'create') - - ACTION REQUIRED: Copy the 'Public Key' to your - server's - ~/.ssh/authorized_keys - file. + + ACTION REQUIRED: Copy the 'Public Key' to your + server's + ~/.ssh/authorized_keys + file. @endif Save @@ -200,7 +217,7 @@

- @elseif ($currentState === 'create-server') + @elseif ($currentState === 'create-server') Please let me know your server details. @@ -208,34 +225,33 @@
- - + +
- -
- -
Non-root user is experimental: docs. +
+
+ +
+ +
+ +
Non-root user is experimental: docs. +
- +
Continue - @elseif ($currentState === 'validate-server') + @elseif ($currentState === 'validate-server') I need to validate your server (connection, Docker Engine, etc) and configure if something is @@ -247,8 +263,7 @@ - + Let's do it! @@ -257,20 +272,19 @@

This will install the latest Docker Engine on your server, configure a few things to be able to run optimal.

Minimum Docker Engine version is: 22

To manually install Docker - Engine, check this + Engine, check this documentation.

- @elseif ($currentState === 'create-project') + @elseif ($currentState === 'create-project') @if (count($projects) > 0) - You already have some projects. Do you want to use one of them or should I create a new one - for - you? + You already have some projects. Do you want to use one of them or should I create a new one + for + you? @else - Let's create an initial project for you. You can change all the details later on. + Let's create an initial project for you. You can change all the details later on. @endif @@ -278,15 +292,15 @@ project!
@if (count($projects) > 0) -
- - @foreach ($projects as $project) - - @endforeach - - Use this Project -
+
+ + @foreach ($projects as $project) + + @endforeach + + Use this Project +
@endif
@@ -297,7 +311,7 @@ staging version of the same application, but grouped separately.

- @elseif ($currentState === 'create-resource') + @elseif ($currentState === 'create-resource') Let's go to the new resource page, where you can create your first resource. @@ -310,24 +324,23 @@

A resource could be an application, a database or a service (like WordPress).

- @endif -
-
-
-
Skip - onboarding
-
Restart - onboarding
+ @endif
- - -
- Feedback -
-
- -
-
-
-
+
+
+
Skip + onboarding
+
Restart + onboarding
+
+ + +
+ Feedback +
+
+ +
+
+ + From 91c845732e24d1bb2e46b645c64030b38022c25b Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:55:34 +0200 Subject: [PATCH 2/5] fix set custom port or user during boarding --- app/Livewire/Boarding/Index.php | 42 ++++++++++++++++++- app/Models/Server.php | 11 ++++- .../views/livewire/boarding/index.blade.php | 10 ++--- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/app/Livewire/Boarding/Index.php b/app/Livewire/Boarding/Index.php index 147a1ad6f..bb01160f4 100644 --- a/app/Livewire/Boarding/Index.php +++ b/app/Livewire/Boarding/Index.php @@ -73,6 +73,8 @@ class Index extends Component } $this->privateKeyName = generate_random_name(); $this->remoteServerName = generate_random_name(); + $this->remoteServerPort = $this->remoteServerPort; + $this->remoteServerUser = $this->remoteServerUser; if (isDev()) { $this->privateKey = '-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW @@ -173,6 +175,8 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== } $this->selectedExistingPrivateKey = $this->createdServer->privateKey->id; $this->serverPublicKey = $this->createdServer->privateKey->publicKey(); + $this->remoteServerPort = $this->createdServer->port; + $this->remoteServerUser = $this->createdServer->user; $this->currentState = 'validate-server'; } @@ -269,7 +273,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== public function validateServer() { try { - config()->set('coolify.mux_enabled', false); + config()->set('coolify.mux_enabled', true); // EC2 does not have `uptime` command, lol instant_remote_process(['ls /'], $this->createdServer, true); @@ -277,9 +281,13 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== $this->createdServer->settings()->update([ 'is_reachable' => true, ]); + $this->serverReachable = true; } catch (\Throwable $e) { $this->serverReachable = false; - $this->createdServer->delete(); + $this->createdServer->settings()->update([ + 'is_reachable' => false, + ]); + return handleError(error: $e, livewire: $this); } @@ -296,6 +304,9 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== ]); $this->getProxyType(); } catch (\Throwable $e) { + $this->createdServer->settings()->update([ + 'is_usable' => false, + ]); return handleError(error: $e, livewire: $this); } } @@ -349,6 +360,33 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== ); } + public function saveAndValidateServer() + { + $this->validate([ + 'remoteServerPort' => 'required|integer|min:1|max:65535', + 'remoteServerUser' => 'required|string', + ]); + + if (!$this->createdServer) { + $this->createdServer = Server::create([ + 'name' => $this->remoteServerName ?? 'New Server', + 'ip' => $this->remoteServerHost, + 'port' => $this->remoteServerPort, + 'user' => $this->remoteServerUser, + 'team_id' => currentTeam()->id, + 'timezone' => 'UTC', + ]); + } else { + $this->createdServer->update([ + 'port' => $this->remoteServerPort, + 'user' => $this->remoteServerUser, + 'timezone' => 'UTC', + ]); + } + + $this->validateServer(); + } + private function createNewPrivateKey() { $this->privateKeyName = generate_random_name(); diff --git a/app/Models/Server.php b/app/Models/Server.php index c72c7cc95..d30cdc9d6 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -112,6 +112,11 @@ class Server extends BaseModel 'proxy', ]; + protected $fillable = [ + 'port', + 'user', + ]; + protected $guarded = []; public static function isReachable() @@ -143,7 +148,11 @@ class Server extends BaseModel public function settings() { - return $this->hasOne(ServerSetting::class); + return $this->hasOne(ServerSetting::class)->withDefault([ + 'force_disabled' => false, + 'is_reachable' => false, + 'is_usable' => false, + ]); } public function setupDefault404Redirect() diff --git a/resources/views/livewire/boarding/index.blade.php b/resources/views/livewire/boarding/index.blade.php index cd7ef4c86..4b1da05da 100644 --- a/resources/views/livewire/boarding/index.blade.php +++ b/resources/views/livewire/boarding/index.blade.php @@ -64,9 +64,9 @@

Please check the connection details below and correct them if they are incorrect.

- +
- +

Non-root user is experimental: docs @@ -88,7 +88,7 @@ - + Check again

@@ -236,9 +236,9 @@ Advanced Settings
- +
- +
Non-root user is experimental: docs.
From d74cfd09ceabdc5faca82e959c989ebe1fe79223 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:18:00 +0200 Subject: [PATCH 3/5] Fixes --- app/Livewire/Boarding/Index.php | 31 ++++----- .../views/livewire/boarding/index.blade.php | 67 ++++++++++++------- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/app/Livewire/Boarding/Index.php b/app/Livewire/Boarding/Index.php index bb01160f4..9503da499 100644 --- a/app/Livewire/Boarding/Index.php +++ b/app/Livewire/Boarding/Index.php @@ -156,6 +156,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== $this->servers = Server::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get(); if ($this->servers->count() > 0) { $this->selectedExistingServer = $this->servers->first()->id; + $this->updateServerDetails(); $this->currentState = 'select-existing-server'; return; @@ -175,11 +176,18 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== } $this->selectedExistingPrivateKey = $this->createdServer->privateKey->id; $this->serverPublicKey = $this->createdServer->privateKey->publicKey(); - $this->remoteServerPort = $this->createdServer->port; - $this->remoteServerUser = $this->createdServer->user; + $this->updateServerDetails(); $this->currentState = 'validate-server'; } + private function updateServerDetails() + { + if ($this->createdServer) { + $this->remoteServerPort = $this->createdServer->port; + $this->remoteServerUser = $this->createdServer->user; + } + } + public function getProxyType() { // Set Default Proxy Type @@ -367,23 +375,12 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== 'remoteServerUser' => 'required|string', ]); - if (!$this->createdServer) { - $this->createdServer = Server::create([ - 'name' => $this->remoteServerName ?? 'New Server', - 'ip' => $this->remoteServerHost, - 'port' => $this->remoteServerPort, - 'user' => $this->remoteServerUser, - 'team_id' => currentTeam()->id, + $this->createdServer->update([ + 'name' => $this->remoteServerName, + 'port' => $this->remoteServerPort, + 'user' => $this->remoteServerUser, 'timezone' => 'UTC', ]); - } else { - $this->createdServer->update([ - 'port' => $this->remoteServerPort, - 'user' => $this->remoteServerUser, - 'timezone' => 'UTC', - ]); - } - $this->validateServer(); } diff --git a/resources/views/livewire/boarding/index.blade.php b/resources/views/livewire/boarding/index.blade.php index 4b1da05da..c826e7b98 100644 --- a/resources/views/livewire/boarding/index.blade.php +++ b/resources/views/livewire/boarding/index.blade.php @@ -64,9 +64,9 @@

Please check the connection details below and correct them if they are incorrect.

- +
- +

Non-root user is experimental: docs @@ -147,11 +147,7 @@

- No - (create - one - for - me) + No (create one for me)
@@ -167,18 +163,39 @@
@if (!$serverReachable) - This server is not reachable with the following public key. -

- Please make sure you have the correct public key in your ~/.ssh/authorized_keys file for - user or skip the boarding process and add a new private key manually to Coolify and to the - server. -
- Check this documentation for further - help. - - Check - again - +
+

Server is not reachable

+

Please check the connection details below and correct them if they are incorrect.

+ +
+ +
+ +

+ Non-root user is experimental: + docs +

+
+
+ +
+

If the connection details are correct, please ensure:

+
    +
  • The correct public key is in your ~/.ssh/authorized_keys file for the specified user
  • +
  • Or skip the boarding process and manually add a new private key to Coolify and the server
  • +
+
+ +

+ For more help, check this documentation. +

+ + + + + Check again + +
@endif @@ -225,27 +242,27 @@
- - + +
- +
- +
- +
Non-root user is experimental: docs.
- +
Continue
From d378bb94bea40dd7208df12390989577bbbee0d0 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:29:53 +0200 Subject: [PATCH 4/5] Fix: remote servers with port and user --- app/Livewire/Boarding/Index.php | 11 ++++++----- app/Models/Server.php | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Livewire/Boarding/Index.php b/app/Livewire/Boarding/Index.php index 9503da499..514f00c3a 100644 --- a/app/Livewire/Boarding/Index.php +++ b/app/Livewire/Boarding/Index.php @@ -247,11 +247,12 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== public function saveServer() { $this->validate([ - 'remoteServerName' => 'required', - 'remoteServerHost' => 'required', + 'remoteServerName' => 'required|string', + 'remoteServerHost' => 'required|string', 'remoteServerPort' => 'required|integer', - 'remoteServerUser' => 'required', + 'remoteServerUser' => 'required|string', ]); + $this->privateKey = formatPrivateKey($this->privateKey); $foundServer = Server::whereIp($this->remoteServerHost)->first(); if ($foundServer) { @@ -379,8 +380,8 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== 'name' => $this->remoteServerName, 'port' => $this->remoteServerPort, 'user' => $this->remoteServerUser, - 'timezone' => 'UTC', - ]); + 'timezone' => 'UTC', + ]); $this->validateServer(); } diff --git a/app/Models/Server.php b/app/Models/Server.php index d30cdc9d6..46536ed47 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -113,8 +113,13 @@ class Server extends BaseModel ]; protected $fillable = [ + 'name', + 'ip', 'port', 'user', + 'description', + 'private_key_id', + 'team_id', ]; protected $guarded = []; @@ -148,11 +153,7 @@ class Server extends BaseModel public function settings() { - return $this->hasOne(ServerSetting::class)->withDefault([ - 'force_disabled' => false, - 'is_reachable' => false, - 'is_usable' => false, - ]); + return $this->hasOne(ServerSetting::class); } public function setupDefault404Redirect() From 2c9491d81c684380d072f663703d6aa61126a1f7 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:43:16 +0200 Subject: [PATCH 5/5] Fix: Do not change localhost server name on revalidation --- app/Livewire/Boarding/Index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Livewire/Boarding/Index.php b/app/Livewire/Boarding/Index.php index 514f00c3a..7f913b79c 100644 --- a/app/Livewire/Boarding/Index.php +++ b/app/Livewire/Boarding/Index.php @@ -377,7 +377,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== ]); $this->createdServer->update([ - 'name' => $this->remoteServerName, 'port' => $this->remoteServerPort, 'user' => $this->remoteServerUser, 'timezone' => 'UTC',