From aabe27efd10e938448791b1e6747c3189bba2128 Mon Sep 17 00:00:00 2001 From: Daniel Alves Date: Thu, 3 Oct 2024 12:58:35 -0300 Subject: [PATCH 01/11] feat: add homarr service tamplate and logo --- public/svgs/homarr.svg | 11 +++++++++++ templates/compose/homarr.yaml | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 public/svgs/homarr.svg create mode 100644 templates/compose/homarr.yaml diff --git a/public/svgs/homarr.svg b/public/svgs/homarr.svg new file mode 100644 index 000000000..4d4289604 --- /dev/null +++ b/public/svgs/homarr.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/templates/compose/homarr.yaml b/templates/compose/homarr.yaml new file mode 100644 index 000000000..7aaf669a1 --- /dev/null +++ b/templates/compose/homarr.yaml @@ -0,0 +1,25 @@ +# documentation: https://homarr.dev +# slogan: Homarr is a self-hosted homepage for your services. +# tags: homarr,self-hosted,homepage +# logo: svgs/homarr.svg +# port: 7575 + +version: "3.8" + +services: + homarr: + image: ghcr.io/ajnart/homarr:latest + container_name: homarr + restart: unless-stopped + environment: + - SERVICE_FQDN_HOMEBOX_7575 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./homarr/configs:/app/data/configs + - ./homarr/icons:/app/public/icons + - ./homarr/data:/data + healthcheck: + test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:7575"] + interval: 5s + timeout: 20s + retries: 10 From c4be720b208178f65c6029825102eee1478bf752 Mon Sep 17 00:00:00 2001 From: Daniel Alves Date: Thu, 3 Oct 2024 15:00:52 -0300 Subject: [PATCH 02/11] fix: update FQDN --- templates/compose/homarr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/compose/homarr.yaml b/templates/compose/homarr.yaml index 7aaf669a1..88087a4ba 100644 --- a/templates/compose/homarr.yaml +++ b/templates/compose/homarr.yaml @@ -12,7 +12,7 @@ services: container_name: homarr restart: unless-stopped environment: - - SERVICE_FQDN_HOMEBOX_7575 + - SERVICE_FQDN_HOMARR_7575 volumes: - /var/run/docker.sock:/var/run/docker.sock - ./homarr/configs:/app/data/configs From 9d6757aeb7de4ab070c9aa6cb516c3844ff0ad45 Mon Sep 17 00:00:00 2001 From: Daniel Alves Date: Thu, 3 Oct 2024 15:52:33 -0300 Subject: [PATCH 03/11] feat: add it-tools service template and logo --- public/svgs/it-tools.svg | 6 ++++++ templates/compose/it-tools.yaml | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 public/svgs/it-tools.svg create mode 100644 templates/compose/it-tools.yaml diff --git a/public/svgs/it-tools.svg b/public/svgs/it-tools.svg new file mode 100644 index 000000000..3de5ecff7 --- /dev/null +++ b/public/svgs/it-tools.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/templates/compose/it-tools.yaml b/templates/compose/it-tools.yaml new file mode 100644 index 000000000..5b691bdca --- /dev/null +++ b/templates/compose/it-tools.yaml @@ -0,0 +1,28 @@ +# documentation: https://github.com/corentinth/it-tools +# slogan: IT Tools is a self-hosted solution for managing various IT tasks. +# tags: it-tools,management,self-hosted +# logo: svgs/it-tools.svg +# port: 8383 + +version: "3.8" + +services: + it-tools: + image: corentinth/it-tools:latest + container_name: it-tools + restart: unless-stopped + environment: + - "SERVICE_FQDN_ITTOOLS=${SERVICE_FQDN_ITTOOLS}" + ports: + - "8383:80" + volumes: + - it-tools-data:/app/data + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:80"] + interval: 30s + timeout: 10s + retries: 3 + +volumes: + it-tools-data: + driver: local From 0b4fc38d6b6060cb7f3af71f81d3f865d40c77a3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 3 Oct 2024 21:10:52 +0200 Subject: [PATCH 04/11] chore: Update version to 4.0.0-beta.354 --- config/sentry.php | 2 +- config/version.php | 2 +- other/nightly/versions.json | 4 ++-- versions.json | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index 5c34fb0f8..28fb12a2c 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.353', + 'release' => '4.0.0-beta.354', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 7cca69456..ef5b5a967 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Thu, 3 Oct 2024 21:11:14 +0200 Subject: [PATCH 05/11] chore: Remove debug statement in Service model --- app/Models/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Models/Service.php b/app/Models/Service.php index 41411ac70..632934524 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -797,7 +797,6 @@ class Service extends BaseModel } } $databases = $this->databases()->get(); - ray($databases); foreach ($databases as $database) { $image = str($database->image)->before(':')->value(); From 5bcd813792ebcb120d14edf6e61baf84e2569fc4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 3 Oct 2024 21:29:04 +0200 Subject: [PATCH 06/11] chore: Remove commented code in Server model --- app/Models/Server.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/Models/Server.php b/app/Models/Server.php index 54942f5fb..3329c9761 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -460,15 +460,6 @@ $schema://$host { public function proxyType() { - // $proxyType = $this->proxy->get('type'); - // if ($proxyType === ProxyTypes::NONE->value) { - // return $proxyType; - // } - // if (is_null($proxyType)) { - // $this->proxy->type = ProxyTypes::TRAEFIK->value; - // $this->proxy->status = ProxyStatus::EXITED->value; - // $this->save(); - // } return data_get($this->proxy, 'type'); } From 5f07b473e9459bfc3267fd7c80c58fdeb9b67111 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 3 Oct 2024 21:29:55 +0200 Subject: [PATCH 07/11] fix: parse proxy config and check the set ports usage --- app/Actions/Proxy/CheckProxy.php | 51 ++++++++++++++----- app/Livewire/Server/Proxy/Status.php | 7 ++- .../components/status/restarting.blade.php | 5 +- .../views/components/status/running.blade.php | 5 +- .../views/components/status/stopped.blade.php | 5 +- .../livewire/server/proxy/status.blade.php | 10 ++-- 6 files changed, 59 insertions(+), 24 deletions(-) diff --git a/app/Actions/Proxy/CheckProxy.php b/app/Actions/Proxy/CheckProxy.php index cf0f6015c..03a0beddf 100644 --- a/app/Actions/Proxy/CheckProxy.php +++ b/app/Actions/Proxy/CheckProxy.php @@ -2,14 +2,17 @@ namespace App\Actions\Proxy; +use App\Enums\ProxyTypes; use App\Models\Server; use Lorisleiva\Actions\Concerns\AsAction; +use Symfony\Component\Yaml\Yaml; class CheckProxy { use AsAction; - public function handle(Server $server, $fromUI = false) + // It should return if the proxy should be started (true) or not (false) + public function handle(Server $server, $fromUI = false): bool { if (! $server->isFunctional()) { return false; @@ -62,22 +65,42 @@ class CheckProxy $ip = 'host.docker.internal'; } - $connection80 = @fsockopen($ip, '80'); - $connection443 = @fsockopen($ip, '443'); - $port80 = is_resource($connection80) && fclose($connection80); - $port443 = is_resource($connection443) && fclose($connection443); - if ($port80) { - if ($fromUI) { - throw new \Exception("Port 80 is in use.
You must stop the process using this port.
Docs: https://coolify.io/docs
Discord: https://coollabs.io/discord"); + $portsToCheck = ['80', '443']; + + try { + if ($server->proxyType() !== ProxyTypes::NONE->value) { + $proxyCompose = CheckConfiguration::run($server); + if (isset($proxyCompose)) { + $yaml = Yaml::parse($proxyCompose); + $portsToCheck = []; + if ($server->proxyType() === ProxyTypes::TRAEFIK->value) { + $ports = data_get($yaml, 'services.traefik.ports'); + } elseif ($server->proxyType() === ProxyTypes::CADDY->value) { + $ports = data_get($yaml, 'services.caddy.ports'); + } + if (isset($ports)) { + foreach ($ports as $port) { + $portsToCheck[] = str($port)->before(':')->value(); + } + } + } } else { - return false; + $portsToCheck = []; } + } catch (\Exception $e) { + ray($e->getMessage()); } - if ($port443) { - if ($fromUI) { - throw new \Exception("Port 443 is in use.
You must stop the process using this port.
Docs: https://coolify.io/docs
Discord: https://coollabs.io/discord"); - } else { - return false; + if (count($portsToCheck) === 0) { + return false; + } + foreach ($portsToCheck as $port) { + $connection = @fsockopen($ip, $port); + if (is_resource($connection) && fclose($connection)) { + if ($fromUI) { + throw new \Exception("Port $port is in use.
You must stop the process using this port.
Docs: https://coolify.io/docs
Discord: https://coollabs.io/discord"); + } else { + return false; + } } } diff --git a/app/Livewire/Server/Proxy/Status.php b/app/Livewire/Server/Proxy/Status.php index 20db4dad4..f4f18381f 100644 --- a/app/Livewire/Server/Proxy/Status.php +++ b/app/Livewire/Server/Proxy/Status.php @@ -4,7 +4,7 @@ namespace App\Livewire\Server\Proxy; use App\Actions\Docker\GetContainersStatus; use App\Actions\Proxy\CheckProxy; -use App\Jobs\ContainerStatusJob; +use App\Actions\Proxy\StartProxy; use App\Models\Server; use Livewire\Component; @@ -44,7 +44,10 @@ class Status extends Component } $this->numberOfPolls++; } - CheckProxy::run($this->server, true); + $shouldStart = CheckProxy::run($this->server, true); + if ($shouldStart) { + StartProxy::run($this->server, false); + } $this->dispatch('proxyStatusUpdated'); if ($this->server->proxy->status === 'running') { $this->polling = false; diff --git a/resources/views/components/status/restarting.blade.php b/resources/views/components/status/restarting.blade.php index fc10a0a75..c9b6c2127 100644 --- a/resources/views/components/status/restarting.blade.php +++ b/resources/views/components/status/restarting.blade.php @@ -2,9 +2,12 @@ 'status' => 'Restarting', 'lastDeploymentInfo' => null, 'lastDeploymentLink' => null, + 'noLoading' => false, ])
- + @if (!$noLoading) + + @endif
diff --git a/resources/views/components/status/running.blade.php b/resources/views/components/status/running.blade.php index 2e0907a2a..8bb45b884 100644 --- a/resources/views/components/status/running.blade.php +++ b/resources/views/components/status/running.blade.php @@ -2,9 +2,12 @@ 'status' => 'Running', 'lastDeploymentInfo' => null, 'lastDeploymentLink' => null, + 'noLoading' => false, ])
- + @if (!$noLoading) + + @endif
diff --git a/resources/views/components/status/stopped.blade.php b/resources/views/components/status/stopped.blade.php index f168fb3c2..63bc2399d 100644 --- a/resources/views/components/status/stopped.blade.php +++ b/resources/views/components/status/stopped.blade.php @@ -1,8 +1,11 @@ @props([ 'status' => 'Stopped', + 'noLoading' => false, ])
- + @if (!$noLoading) + + @endif
{{ str($status)->before(':')->headline() }}
diff --git a/resources/views/livewire/server/proxy/status.blade.php b/resources/views/livewire/server/proxy/status.blade.php index 621e0bc8c..4dce706e8 100644 --- a/resources/views/livewire/server/proxy/status.blade.php +++ b/resources/views/livewire/server/proxy/status.blade.php @@ -1,14 +1,14 @@
@if (data_get($server, 'proxy.status') === 'running') - + @elseif (data_get($server, 'proxy.status') === 'restarting') - + @elseif (data_get($server, 'proxy.force_stop')) - + @elseif (data_get($server, 'proxy.status') === 'exited') - + @else - + @endif Refresh
From 33cb2d150df952c9e867941c9d4493e60e99f02f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 3 Oct 2024 21:32:02 +0200 Subject: [PATCH 08/11] chore: Fix application deployment queue filter logic --- app/Console/Commands/CheckApplicationDeploymentQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/CheckApplicationDeploymentQueue.php b/app/Console/Commands/CheckApplicationDeploymentQueue.php index 9f66e058e..e89d26f2c 100644 --- a/app/Console/Commands/CheckApplicationDeploymentQueue.php +++ b/app/Console/Commands/CheckApplicationDeploymentQueue.php @@ -18,7 +18,7 @@ class CheckApplicationDeploymentQueue extends Command $deployments = ApplicationDeploymentQueue::whereIn('status', [ ApplicationDeploymentStatus::IN_PROGRESS, ApplicationDeploymentStatus::QUEUED, - ])->where('created_at', '>=', now()->subSeconds($seconds))->get(); + ])->where('created_at', '<=', now()->subSeconds($seconds))->get(); if ($deployments->isEmpty()) { $this->info('No deployments found in the last '.$seconds.' seconds.'); From 358f6575f86054e7e487ecae1177d56bdf0f12c0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 3 Oct 2024 21:38:08 +0200 Subject: [PATCH 09/11] chore: Refactor modal-confirmation component --- resources/views/components/modal-confirmation.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php index fbf0d4553..ad2ebe196 100644 --- a/resources/views/components/modal-confirmation.blade.php +++ b/resources/views/components/modal-confirmation.blade.php @@ -151,9 +151,9 @@ @endif @endif