diff --git a/app/Actions/Proxy/CheckProxy.php b/app/Actions/Proxy/CheckProxy.php index 32673abc9..ccefa8681 100644 --- a/app/Actions/Proxy/CheckProxy.php +++ b/app/Actions/Proxy/CheckProxy.php @@ -21,7 +21,10 @@ class CheckProxy $status = getContainerStatus($server, 'coolify-proxy_traefik'); $server->proxy->set('status', $status); $server->save(); - return false; + if ($status === 'running') { + return false; + } + return true; } else { $status = getContainerStatus($server, 'coolify-proxy'); if ($status === 'running') { diff --git a/app/Livewire/Project/New/Select.php b/app/Livewire/Project/New/Select.php index b205467bf..80a41d7c7 100644 --- a/app/Livewire/Project/New/Select.php +++ b/app/Livewire/Project/New/Select.php @@ -123,7 +123,7 @@ class Select extends Component $this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false); break; } - if (str($type)->startsWith('one-click-service')) { + if (str($type)->startsWith('one-click-service') || str($type)->startsWith('docker-compose-empty') || str($type)->startsWith('docker-image')) { $this->isDatabase = true; $this->includeSwarm = false; $this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false); diff --git a/app/Livewire/Server/New/ByIp.php b/app/Livewire/Server/New/ByIp.php index 98e7a99a7..1849cdfbc 100644 --- a/app/Livewire/Server/New/ByIp.php +++ b/app/Livewire/Server/New/ByIp.php @@ -23,8 +23,9 @@ class ByIp extends Component public int $port = 22; public bool $is_swarm_manager = false; public bool $is_swarm_worker = false; + public $selected_swarm_cluster = null; - + public $swarm_managers = []; protected $rules = [ 'name' => 'required|string', 'description' => 'nullable|string', @@ -48,6 +49,10 @@ class ByIp extends Component { $this->name = generate_random_name(); $this->private_key_id = $this->private_keys->first()->id; + $this->swarm_managers = Server::isUsable()->get()->where('settings.is_swarm_manager', true); + if ($this->swarm_managers->count() > 0) { + $this->selected_swarm_cluster = $this->swarm_managers->first()->id; + } } public function setPrivateKey(string $private_key_id) @@ -57,7 +62,7 @@ class ByIp extends Component public function instantSave() { - $this->dispatch('success', 'Application settings updated!'); + // $this->dispatch('success', 'Application settings updated!'); } public function submit() @@ -67,7 +72,7 @@ class ByIp extends Component if (is_null($this->private_key_id)) { return $this->dispatch('error', 'You must select a private key'); } - $server = Server::create([ + $payload = [ 'name' => $this->name, 'description' => $this->description, 'ip' => $this->ip, @@ -79,7 +84,11 @@ class ByIp extends Component "type" => ProxyTypes::TRAEFIK_V2->value, "status" => ProxyStatus::EXITED->value, ], - ]); + ]; + if ($this->is_swarm_worker) { + $payload['swarm_cluster'] = $this->selected_swarm_cluster; + } + $server = Server::create($payload); $server->settings->is_swarm_manager = $this->is_swarm_manager; $server->settings->is_swarm_worker = $this->is_swarm_worker; $server->settings->save(); diff --git a/database/migrations/2023_12_19_124111_add_swarm_cluster_grouping.php b/database/migrations/2023_12_19_124111_add_swarm_cluster_grouping.php new file mode 100644 index 000000000..668acb6fe --- /dev/null +++ b/database/migrations/2023_12_19_124111_add_swarm_cluster_grouping.php @@ -0,0 +1,28 @@ +integer('swarm_cluster')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('servers', function (Blueprint $table) { + $table->dropColumn('swarm_cluster'); + }); + } +}; diff --git a/resources/views/components/status/index.blade.php b/resources/views/components/status/index.blade.php index 050025f94..08d6b3cc2 100644 --- a/resources/views/components/status/index.blade.php +++ b/resources/views/components/status/index.blade.php @@ -1,6 +1,6 @@ @if (Str::of($status)->startsWith('running')) -@elseif(Str::of($status)->startsWith('restarting')) +@elseif(Str::of($status)->startsWith('restarting') || Str::of($status)->startsWith('starting')) @else diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index ae638b8ee..0d999aed6 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -205,7 +205,7 @@ @if ($isDatabase)
here." label="Include Swarm Clusters" />
diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 6219a5136..a96ff4296 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -54,26 +54,28 @@ - {{-- @if ($server->settings->is_swarm_worker) + @if ($server->isSwarm()) +
Swarm support is in alpha version.
+ @endif + @if ($server->settings->is_swarm_worker) + label="Is it a Swarm Manager?" /> @else + label="Is it a Swarm Manager?" /> @endif @if ($server->settings->is_swarm_manager) + label="Is it a Swarm Worker?" /> @else - @endif --}} + label="Is it a Swarm Worker?" /> + @endif @endif - diff --git a/resources/views/livewire/server/new/by-ip.blade.php b/resources/views/livewire/server/new/by-ip.blade.php index 3723ccfab..3b958c0b3 100644 --- a/resources/views/livewire/server/new/by-ip.blade.php +++ b/resources/views/livewire/server/new/by-ip.blade.php @@ -25,26 +25,40 @@ @endif @endforeach - {{--
+
+
Swarm support is in alpha version.
@if ($is_swarm_worker) + label="Is it a Swarm Manager?" /> @else - + label="Is it a Swarm Manager?" /> @endif @if ($is_swarm_manager) + label="Is it a Swarm Worker?" /> @else - + label="Is it a Swarm Worker?" /> @endif -
--}} + @if ($is_swarm_worker) +
+ + @foreach ($swarm_managers as $server) + @if ($loop->first) + + @else + + @endif + @endforeach + +
+ @endif +
Save New Server