add swarm server grouping
fixes for swarm
This commit is contained in:
@@ -21,7 +21,10 @@ class CheckProxy
|
|||||||
$status = getContainerStatus($server, 'coolify-proxy_traefik');
|
$status = getContainerStatus($server, 'coolify-proxy_traefik');
|
||||||
$server->proxy->set('status', $status);
|
$server->proxy->set('status', $status);
|
||||||
$server->save();
|
$server->save();
|
||||||
return false;
|
if ($status === 'running') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$status = getContainerStatus($server, 'coolify-proxy');
|
$status = getContainerStatus($server, 'coolify-proxy');
|
||||||
if ($status === 'running') {
|
if ($status === 'running') {
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class Select extends Component
|
|||||||
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false);
|
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false);
|
||||||
break;
|
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->isDatabase = true;
|
||||||
$this->includeSwarm = false;
|
$this->includeSwarm = false;
|
||||||
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false);
|
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false);
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ class ByIp extends Component
|
|||||||
public int $port = 22;
|
public int $port = 22;
|
||||||
public bool $is_swarm_manager = false;
|
public bool $is_swarm_manager = false;
|
||||||
public bool $is_swarm_worker = false;
|
public bool $is_swarm_worker = false;
|
||||||
|
public $selected_swarm_cluster = null;
|
||||||
|
|
||||||
|
public $swarm_managers = [];
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
@@ -48,6 +49,10 @@ class ByIp extends Component
|
|||||||
{
|
{
|
||||||
$this->name = generate_random_name();
|
$this->name = generate_random_name();
|
||||||
$this->private_key_id = $this->private_keys->first()->id;
|
$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)
|
public function setPrivateKey(string $private_key_id)
|
||||||
@@ -57,7 +62,7 @@ class ByIp extends Component
|
|||||||
|
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
$this->dispatch('success', 'Application settings updated!');
|
// $this->dispatch('success', 'Application settings updated!');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
@@ -67,7 +72,7 @@ class ByIp extends Component
|
|||||||
if (is_null($this->private_key_id)) {
|
if (is_null($this->private_key_id)) {
|
||||||
return $this->dispatch('error', 'You must select a private key');
|
return $this->dispatch('error', 'You must select a private key');
|
||||||
}
|
}
|
||||||
$server = Server::create([
|
$payload = [
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'ip' => $this->ip,
|
'ip' => $this->ip,
|
||||||
@@ -79,7 +84,11 @@ class ByIp extends Component
|
|||||||
"type" => ProxyTypes::TRAEFIK_V2->value,
|
"type" => ProxyTypes::TRAEFIK_V2->value,
|
||||||
"status" => ProxyStatus::EXITED->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_manager = $this->is_swarm_manager;
|
||||||
$server->settings->is_swarm_worker = $this->is_swarm_worker;
|
$server->settings->is_swarm_worker = $this->is_swarm_worker;
|
||||||
$server->settings->save();
|
$server->settings->save();
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->integer('swarm_cluster')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('swarm_cluster');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
@if (Str::of($status)->startsWith('running'))
|
@if (Str::of($status)->startsWith('running'))
|
||||||
<x-status.running :status="$status" />
|
<x-status.running :status="$status" />
|
||||||
@elseif(Str::of($status)->startsWith('restarting'))
|
@elseif(Str::of($status)->startsWith('restarting') || Str::of($status)->startsWith('starting'))
|
||||||
<x-status.restarting :status="$status" />
|
<x-status.restarting :status="$status" />
|
||||||
@else
|
@else
|
||||||
<x-status.stopped :status="$status" />
|
<x-status.stopped :status="$status" />
|
||||||
|
|||||||
@@ -205,7 +205,7 @@
|
|||||||
@if ($isDatabase)
|
@if ($isDatabase)
|
||||||
<div class="flex items-center justify-center pt-4">
|
<div class="flex items-center justify-center pt-4">
|
||||||
<x-forms.checkbox instantSave wire:model="includeSwarm"
|
<x-forms.checkbox instantSave wire:model="includeSwarm"
|
||||||
helper="Swarm clusters are excluded from this list by default. For database (or services with database) to work with Swarm,
|
helper="Swarm clusters are excluded from this list by default. For database, services or complex compose deployments with databases to work with Swarm,
|
||||||
you need to set a few things on the server. Read more <a class='text-white underline' href='https://coolify.io/docs/swarm#database-requirements' target='_blank'>here</a>."
|
you need to set a few things on the server. Read more <a class='text-white underline' href='https://coolify.io/docs/swarm#database-requirements' target='_blank'>here</a>."
|
||||||
label="Include Swarm Clusters" />
|
label="Include Swarm Clusters" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -54,26 +54,28 @@
|
|||||||
<x-forms.checkbox instantSave
|
<x-forms.checkbox instantSave
|
||||||
helper="If you are using Cloudflare Tunnels, enable this. It will proxy all ssh requests to your server through Cloudflare.<span class='text-warning'>Coolify does not install/setup Cloudflare (cloudflared) on your server.</span>"
|
helper="If you are using Cloudflare Tunnels, enable this. It will proxy all ssh requests to your server through Cloudflare.<span class='text-warning'>Coolify does not install/setup Cloudflare (cloudflared) on your server.</span>"
|
||||||
id="server.settings.is_cloudflare_tunnel" label="Cloudflare Tunnel" />
|
id="server.settings.is_cloudflare_tunnel" label="Cloudflare Tunnel" />
|
||||||
{{-- @if ($server->settings->is_swarm_worker)
|
@if ($server->isSwarm())
|
||||||
|
<div class="pt-6"> Swarm support is in alpha version. </div>
|
||||||
|
@endif
|
||||||
|
@if ($server->settings->is_swarm_worker)
|
||||||
<x-forms.checkbox disabled instantSave type="checkbox" id="server.settings.is_swarm_manager"
|
<x-forms.checkbox disabled instantSave type="checkbox" id="server.settings.is_swarm_manager"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Manager?<span class='font-bold text-warning'>(alpha)</span>" />
|
label="Is it a Swarm Manager?" />
|
||||||
@else
|
@else
|
||||||
<x-forms.checkbox instantSave type="checkbox" id="server.settings.is_swarm_manager"
|
<x-forms.checkbox instantSave type="checkbox" id="server.settings.is_swarm_manager"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Manager?<span class='font-bold text-warning'>(alpha)</span>"" />
|
label="Is it a Swarm Manager?" />
|
||||||
@endif
|
@endif
|
||||||
@if ($server->settings->is_swarm_manager)
|
@if ($server->settings->is_swarm_manager)
|
||||||
<x-forms.checkbox disabled instantSave type="checkbox" id="server.settings.is_swarm_worker"
|
<x-forms.checkbox disabled instantSave type="checkbox" id="server.settings.is_swarm_worker"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Worker?<span class='font-bold text-warning'>(alpha)</span>" />
|
label="Is it a Swarm Worker?" />
|
||||||
@else
|
@else
|
||||||
<x-forms.checkbox instantSave type="checkbox" id="server.settings.is_swarm_worker"
|
<x-forms.checkbox instantSave type="checkbox" id="server.settings.is_swarm_worker"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Worker?<span class='font-bold text-warning'>(alpha)</span>" />
|
label="Is it a Swarm Worker?" />
|
||||||
@endif --}}
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -25,26 +25,40 @@
|
|||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-forms.select>
|
</x-forms.select>
|
||||||
{{-- <div class="w-72">
|
<div class="w-72">
|
||||||
|
<div class="pt-6"> Swarm support is in alpha version. </div>
|
||||||
@if ($is_swarm_worker)
|
@if ($is_swarm_worker)
|
||||||
<x-forms.checkbox disabled instantSave type="checkbox" id="is_swarm_manager"
|
<x-forms.checkbox disabled instantSave type="checkbox" id="is_swarm_manager"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Manager?<span class='font-bold text-warning'>(alpha)</span>" />
|
label="Is it a Swarm Manager?" />
|
||||||
@else
|
@else
|
||||||
<x-forms.checkbox instantSave type="checkbox" id="is_swarm_manager"
|
<x-forms.checkbox type="checkbox" instantSave id="is_swarm_manager"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Manager?<span class='font-bold text-warning'>(alpha)</span>" />
|
label="Is it a Swarm Manager?" />
|
||||||
@endif
|
@endif
|
||||||
@if ($is_swarm_manager)
|
@if ($is_swarm_manager)
|
||||||
<x-forms.checkbox disabled instantSave type="checkbox" id="is_swarm_worker"
|
<x-forms.checkbox disabled instantSave type="checkbox" id="is_swarm_worker"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Worker?<span class='font-bold text-warning'>(alpha)</span>" />
|
label="Is it a Swarm Worker?" />
|
||||||
@else
|
@else
|
||||||
<x-forms.checkbox instantSave type="checkbox" id="is_swarm_worker"
|
<x-forms.checkbox type="checkbox" instantSave id="is_swarm_worker"
|
||||||
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
helper="For more information, please read the documentation <a class='text-white' href='https://coolify.io/docs/swarm' target='_blank'>here</a>."
|
||||||
label="Is it a Swarm Worker?<span class='font-bold text-warning'>(alpha)</span>" />
|
label="Is it a Swarm Worker?" />
|
||||||
@endif
|
@endif
|
||||||
</div> --}}
|
@if ($is_swarm_worker)
|
||||||
|
<div class="py-4">
|
||||||
|
<x-forms.select label="Select a Swarm Cluster" id="selected_swarm_cluster" required>
|
||||||
|
@foreach ($swarm_managers as $server)
|
||||||
|
@if ($loop->first)
|
||||||
|
<option selected value="{{ $server->id }}">{{ $server->name }}</option>
|
||||||
|
@else
|
||||||
|
<option value="{{ $server->id }}">{{ $server->name }}</option>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</x-forms.select>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
<x-forms.button type="submit">
|
<x-forms.button type="submit">
|
||||||
Save New Server
|
Save New Server
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
|||||||
Reference in New Issue
Block a user