From 982f5beaf5e6b38d4f546763a0c8e14c92cc187a Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Fri, 5 May 2023 16:56:03 +0100 Subject: [PATCH 1/9] Fix Mux as env variable. --- app/Actions/Proxy/InstallProxy.php | 1 + bootstrap/helpers.php | 2 +- config/coolify.php | 2 ++ vite.config.js | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.php index fb908b3d4..84429c7cf 100644 --- a/app/Actions/Proxy/InstallProxy.php +++ b/app/Actions/Proxy/InstallProxy.php @@ -19,6 +19,7 @@ class InstallProxy ); $activity = remoteProcess([ + "docker network ls --format '{{.Name}}' | grep '^coolify$' || docker network create coolify", 'mkdir -p projects', 'mkdir -p projects/proxy', 'mkdir -p projects/proxy/letsencrypt', diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index d913fb94f..2fc9b77b8 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -87,7 +87,7 @@ if (!function_exists('generateSshCommand')) { $delimiter = 'EOF-COOLIFY-SSH'; Storage::disk('local')->makeDirectory('.ssh'); $ssh_command = "ssh "; - if ($isMux) { + if ($isMux && config('coolify.mux_enabled')) { $ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/.ssh/ssh_mux_%h_%p_%r '; } $ssh_command .= "-i {$private_key_location} " diff --git a/config/coolify.php b/config/coolify.php index 5438c7dab..95960c648 100644 --- a/config/coolify.php +++ b/config/coolify.php @@ -2,4 +2,6 @@ return [ 'version' => '4.0.0-nightly.2', + + 'mux_enabled' => env('MUX_ENABLED', true), ]; diff --git a/vite.config.js b/vite.config.js index ede21f48c..d999b843c 100644 --- a/vite.config.js +++ b/vite.config.js @@ -6,9 +6,9 @@ export default defineConfig({ host: "0.0.0.0", hmr: process.env.GITPOD_WORKSPACE_URL ? { - // Due to port fowarding, we have to replace + // Due to port forwarding, we have to replace // 'https' with the forwarded port, as this - // is the URI created by Gitpod. + // is the URI created by GitPod. host: process.env.GITPOD_WORKSPACE_URL.replace( "https://", "5173-" From 931664c0c0f85059cf5270eabe28faf2a1ca2c5a Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Fri, 12 May 2023 19:15:36 +0100 Subject: [PATCH 2/9] wip --- app/Actions/Proxy/InstallProxy.php | 10 ++-- app/Http/Livewire/Server/Proxy.php | 13 +++++ docker/dev-ssu/Dockerfile | 5 ++ .../livewire/server/_proxy/loading.blade.php | 12 +++++ .../livewire/server/_proxy/options.blade.php | 48 +++++++++++++++++++ .../livewire/server/_proxy/problems.blade.php | 5 ++ .../views/livewire/server/proxy.blade.php | 27 +++++++---- resources/views/server/show.blade.php | 1 - scripts/run | 3 ++ 9 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 resources/views/livewire/server/_proxy/loading.blade.php create mode 100644 resources/views/livewire/server/_proxy/options.blade.php create mode 100644 resources/views/livewire/server/_proxy/problems.blade.php diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.php index 84429c7cf..42864b415 100644 --- a/app/Actions/Proxy/InstallProxy.php +++ b/app/Actions/Proxy/InstallProxy.php @@ -3,12 +3,14 @@ namespace App\Actions\Proxy; use App\Enums\ActivityTypes; +use App\Enums\ProxyTypes; use App\Models\Server; +use Spatie\Activitylog\Models\Activity; use Symfony\Component\Yaml\Yaml; class InstallProxy { - public function __invoke(Server $server) + public function __invoke(Server $server): Activity { $docker_compose_yml_base64 = base64_encode( $this->getDockerComposeContents() @@ -30,6 +32,10 @@ class InstallProxy 'docker ps', ], $server, ActivityTypes::INLINE->value); + // Persist to Database + $server->extra_attributes->proxy = ProxyTypes::TRAEFIK_V2->value; + $server->save(); + return $activity; } @@ -47,8 +53,6 @@ class InstallProxy ? config('proxy.project_path_on_host') . '/_testing_hosts/host_2_proxy' : '.'; - ray($cwd); - return [ "version" => "3.7", "networks" => [ diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php index bc4298287..a44bb9e6d 100644 --- a/app/Http/Livewire/Server/Proxy.php +++ b/app/Http/Livewire/Server/Proxy.php @@ -13,6 +13,11 @@ class Proxy extends Component protected string $selectedProxy = ''; + public $is_proxy_installed; + + public $is_check_proxy_complete = false; + public $is_proxy_settings_in_sync = false; + public function mount(Server $server) { $this->server = $server; @@ -25,6 +30,14 @@ class Proxy extends Component $this->emit('newMonitorActivity', $activity->id); } + public function checkProxySettingsInSync() + { + + + $this->is_check_proxy_complete = true; + $this->is_proxy_settings_in_sync = true; + } + public function render() { return view('livewire.server.proxy'); diff --git a/docker/dev-ssu/Dockerfile b/docker/dev-ssu/Dockerfile index c90e53d08..e8724828e 100644 --- a/docker/dev-ssu/Dockerfile +++ b/docker/dev-ssu/Dockerfile @@ -5,4 +5,9 @@ RUN apt-get -y autoremove \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* +RUN echo "alias ll='ls -al'" >> /etc/bash.bashrc +RUN echo "alias a='php artisan'" >> /etc/bash.bashrc +RUN echo "alias mfs='php artisan migrate:fresh --seed'" >> /etc/bash.bashrc +RUN echo "alias cda='composer dump-autoload'" >> /etc/bash.bashrc + # COPY --chmod=755 docker/dev-ssu/etc/s6-overlay/ /etc/s6-overlay/ diff --git a/resources/views/livewire/server/_proxy/loading.blade.php b/resources/views/livewire/server/_proxy/loading.blade.php new file mode 100644 index 000000000..cfab2d8db --- /dev/null +++ b/resources/views/livewire/server/_proxy/loading.blade.php @@ -0,0 +1,12 @@ +
+
+ Loading +
+
+ + + + +
+
diff --git a/resources/views/livewire/server/_proxy/options.blade.php b/resources/views/livewire/server/_proxy/options.blade.php new file mode 100644 index 000000000..e6610bc27 --- /dev/null +++ b/resources/views/livewire/server/_proxy/options.blade.php @@ -0,0 +1,48 @@ + +
+ +
+ +
+ +
+ + + +
+ +
+ +
+ +
+ diff --git a/resources/views/livewire/server/_proxy/problems.blade.php b/resources/views/livewire/server/_proxy/problems.blade.php new file mode 100644 index 000000000..541d15e6a --- /dev/null +++ b/resources/views/livewire/server/_proxy/problems.blade.php @@ -0,0 +1,5 @@ +
+
+ Problems! +
+
diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php index 91832611c..6feb45043 100644 --- a/resources/views/livewire/server/proxy.blade.php +++ b/resources/views/livewire/server/proxy.blade.php @@ -2,20 +2,29 @@

Proxy

@if($this->server->extra_attributes->proxy) -
+
Proxy type: {{ $this->server->extra_attributes->proxy }}
-
Features in W11.
-
    -
  • Edit config file
  • -
  • Enable dashboard (blocking port by firewall)
  • -
  • Dashboard access - login/password
  • -
  • Setup host for Traefik Dashboard
  • -
  • Visit (nav to traefik dashboard)
  • -
+ +
+ + {{-- Proxy is being checked against DB information --}} + @if(! $this->is_check_proxy_complete) + @include('livewire.server._proxy.loading') + @endif + + @if($this->is_check_proxy_complete && (! $this->is_proxy_settings_in_sync) ) + @include('livewire.server._proxy.problems') + @endif + + @include('livewire.server._proxy.options') +
+
@else + {{-- There is no Proxy installed --}} + No proxy installed. +
From 3ba4a5cfb52e592b5808c542ce05aa88a1cb99d9 Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Fri, 12 May 2023 19:51:07 +0100 Subject: [PATCH 4/9] wip --- app/Actions/Proxy/CheckProxySettingsInSync.php | 11 ++++++++++- app/Http/Livewire/Server/Proxy.php | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Actions/Proxy/CheckProxySettingsInSync.php b/app/Actions/Proxy/CheckProxySettingsInSync.php index 98225d414..0a63a0735 100644 --- a/app/Actions/Proxy/CheckProxySettingsInSync.php +++ b/app/Actions/Proxy/CheckProxySettingsInSync.php @@ -17,8 +17,17 @@ class CheckProxySettingsInSync ProxyTypes::TRAEFIK_V2->value => 'proxy', }; - return instantRemoteProcess([ + $container_name = 'coolify-proxy'; + + $output = instantRemoteProcess([ 'if [ -d "projects/'.$folder_name.'" ]; then echo "true"; else echo "false"; fi', + <</dev/null)" == "true" ]] && echo "true" || echo "false" + EOT, ], $server); + + return collect( + explode(PHP_EOL, $output) + )->every(fn($output) => $output === 'true'); } } diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php index 40fe2e4cc..16e92cf48 100644 --- a/app/Http/Livewire/Server/Proxy.php +++ b/app/Http/Livewire/Server/Proxy.php @@ -33,9 +33,9 @@ class Proxy extends Component public function checkProxySettingsInSync() { - $status = resolve(CheckProxySettingsInSync::class)($this->server); + $this->is_proxy_settings_in_sync = resolve(CheckProxySettingsInSync::class)($this->server); + $this->is_check_proxy_complete = true; - $this->is_proxy_settings_in_sync = $status === 'true'; } public function render() From 35f8911b1be5b2bfe1d338860a6c4419de0daa01 Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Fri, 12 May 2023 20:06:13 +0100 Subject: [PATCH 5/9] wip --- app/Actions/Proxy/CheckProxySettingsInSync.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Actions/Proxy/CheckProxySettingsInSync.php b/app/Actions/Proxy/CheckProxySettingsInSync.php index 0a63a0735..dc72e1dd7 100644 --- a/app/Actions/Proxy/CheckProxySettingsInSync.php +++ b/app/Actions/Proxy/CheckProxySettingsInSync.php @@ -20,7 +20,9 @@ class CheckProxySettingsInSync $container_name = 'coolify-proxy'; $output = instantRemoteProcess([ + // Folder exists, in ~/projects/ 'if [ -d "projects/'.$folder_name.'" ]; then echo "true"; else echo "false"; fi', + // Container of name is running <</dev/null)" == "true" ]] && echo "true" || echo "false" EOT, From 86afa200cdb706221f56c0d3e473fe097c00554c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 14 May 2023 14:43:49 +0200 Subject: [PATCH 6/9] ui changes --- app/Http/Livewire/Server/Form.php | 2 +- resources/css/app.css | 9 +-- .../views/components/inputs/button.blade.php | 14 +++-- .../views/components/magic-bar.blade.php | 2 +- resources/views/components/navbar.blade.php | 60 ++++++++++--------- .../views/livewire/activity-monitor.blade.php | 14 ++--- .../views/livewire/run-command.blade.php | 2 +- .../views/livewire/server/form.blade.php | 29 ++++++--- .../views/livewire/server/proxy.blade.php | 12 ++-- resources/views/server/show.blade.php | 24 +++++--- 10 files changed, 97 insertions(+), 71 deletions(-) diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 923006789..ed2fc38b4 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -32,7 +32,7 @@ class Form extends Component $this->emit('newMonitorActivity', $activity->id); } - public function checkServer() + public function validateServer() { try { $this->uptime = instantRemoteProcess(['uptime'], $this->server, false); diff --git a/resources/css/app.css b/resources/css/app.css index 7781ba274..19dd8f947 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -6,8 +6,9 @@ body { @apply bg-coolgray-100 text-white font-sans; } -input, textarea { - @apply border-none p-2 bg-coolgray-200 text-white disabled:text-neutral-600 read-only:text-neutral-600 read-only:select-none outline-none ; +input, +textarea { + @apply border-none p-2 bg-coolgray-200 text-white disabled:text-neutral-600 read-only:text-neutral-600 read-only:select-none outline-none; } select { @apply border-none p-2 bg-coolgray-200 text-white disabled:text-neutral-600 read-only:select-none outline-none; @@ -20,11 +21,11 @@ button { @apply relative float-left; } .main-menu:after { - content: '/'; + content: "/"; @apply absolute right-0 top-0 text-neutral-400 px-2 pt-[0.3rem]; } .magic-input { - @apply w-[25rem] rounded shadow outline-none focus:bg-neutral-700 text-white; + @apply w-[25rem] rounded outline-none bg-coolgray-400 focus:bg-neutral-700 text-white; } .magic-items { @apply absolute top-14 w-[25rem] bg-coolgray-200 border-b-2 border-r-2 border-l-2 border-solid border-coolgray-100 rounded-b; diff --git a/resources/views/components/inputs/button.blade.php b/resources/views/components/inputs/button.blade.php index f1b42b1e3..93dcace54 100644 --- a/resources/views/components/inputs/button.blade.php +++ b/resources/views/components/inputs/button.blade.php @@ -1,17 +1,21 @@ @props([ 'isWarning' => null, + 'isBold' => false, 'disabled' => null, - 'defaultClass' => 'text-white hover:bg-coollabs h-8 rounded transition-colors', - 'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-8 rounded', - 'disabledClass' => 'text-coolgray-200 h-8 rounded', - 'loadingClass' => 'text-black bg-green-500 h-8 rounded', + 'defaultClass' => 'text-white hover:bg-coollabs h-10 rounded transition-colors', + 'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-10 rounded', + 'disabledClass' => 'text-neutral-400 h-10 rounded', + 'loadingClass' => 'text-black bg-green-500 h-10 rounded', 'confirm' => null, 'confirmAction' => null, ])