Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(v5): add WireGuard and coold/corrosion config to clusters/servers

Andras Bacsai3ae87334bd2b
diff --git a/.dev/lima/coolify-naked-test.yaml b/.dev/lima/coolify-naked-test.yaml
new file mode 100644
index 0000000000..90850f5519
--- /dev/null
+++ b/.dev/lima/coolify-naked-test.yaml
@@ -0,0 +1,32 @@
+vmType: "vz"
+arch: "default"
+cpus: 2
+memory: "2GiB"
+disk: "20GiB"
+containerd:
+ system: false
+ user: false
+ssh:
+ localPort: 60003
+images:
+ - location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
+ arch: "x86_64"
+ - location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
+ arch: "aarch64"
+mounts: []
+provision:
+ - mode: system
+ script: |
+ #!/usr/bin/env bash
+ set -euxo pipefail
+ export DEBIAN_FRONTEND=noninteractive
+ install -d -m 700 /root/.ssh
+ cat >/root/.ssh/authorized_keys <<'KEYS'
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuGmoeGq/pojrsyP1pszcNVuZx9iFkCELtxrh31QJ68 sail@76ff66d2e2dd
+ KEYS
+ chmod 600 /root/.ssh/authorized_keys
+ sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
+ sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
+ systemctl restart ssh || systemctl restart sshd
+ apt-get update
+ apt-get install -y --no-install-recommends ca-certificates curl openssh-server sudo
diff --git a/.dev/testing-host-key b/.dev/testing-host-key
new file mode 100644
index 0000000000..c67d90a641
--- /dev/null
+++ b/.dev/testing-host-key
@@ -0,0 +1,7 @@
+-----BEGIN OPENSSH PRIVATE KEY-----
+b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk
+hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA
+AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
+uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
+-----END OPENSSH PRIVATE KEY-----
diff --git a/.dev/testing-host-key.pub b/.dev/testing-host-key.pub
new file mode 100644
index 0000000000..802cd8b809
--- /dev/null
+++ b/.dev/testing-host-key.pub
@@ -0,0 +1 @@
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuGmoeGq/pojrsyP1pszcNVuZx9iFkCELtxrh31QJ68 sail@76ff66d2e2dd
diff --git a/app/Console/Commands/V5SyncDevLimaServers.php b/app/Console/Commands/V5SyncDevLimaServers.php
index b6f30ebef0..d55e3531f6 100644
--- a/app/Console/Commands/V5SyncDevLimaServers.php
+++ b/app/Console/Commands/V5SyncDevLimaServers.php
@@ -33,7 +33,13 @@ class V5SyncDevLimaServers extends Command
$team = Team::query()->find((int) $this->option('team-id')) ?? Team::query()->orderBy('id')->first();
$user = User::query()->find((int) $this->option('user-id')) ?? User::query()->orderBy('id')->first();
$privateKeyId = $this->option('private-key-id');
- $privateKey = is_numeric($privateKeyId) ? PrivateKey::query()->find((int) $privateKeyId) : null;
+ $privateKey = is_numeric($privateKeyId)
+ ? PrivateKey::query()->find((int) $privateKeyId)
+ : PrivateKey::query()
+ ->where('team_id', $team?->id)
+ ->where('is_git_related', false)
+ ->orderBy('id')
+ ->first();
if (! $team instanceof Team || ! $user instanceof User) {
$this->warn('Cannot sync dev Lima servers without an existing team and user.');
@@ -74,14 +80,14 @@ class V5SyncDevLimaServers extends Command
Server::query()->updateOrCreate([
'team_id' => $team->id,
- 'host' => $host,
- 'ssh_port' => (int) $sshPort,
- ], [
'cluster_id' => $cluster->id,
+ 'name' => $name,
+ ], [
'created_by_user_id' => $user->id,
'private_key_id' => $privateKey?->id,
- 'name' => $name,
+ 'host' => $host,
'ssh_user' => $sshUser,
+ 'ssh_port' => (int) $sshPort,
'status' => 'installed',
'capabilities' => $capabilities,
'builder_enabled' => $builderEnabled,
diff --git a/app/Http/Controllers/V5/DashboardController.php b/app/Http/Controllers/V5/DashboardController.php
index 0e1c5a283e..ef4a9a3769 100644
--- a/app/Http/Controllers/V5/DashboardController.php
+++ b/app/Http/Controllers/V5/DashboardController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\V5;
use App\Http\Controllers\Controller;
use App\Models\Environment;
+use App\Models\PrivateKey;
use App\Models\Project;
use App\Models\Team;
use App\Models\V5\Cluster as V5Cluster;
@@ -12,6 +13,8 @@ use App\Services\Flux\FluxHealth;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Process;
use Illuminate\Validation\Rule;
use Inertia\Inertia;
use Inertia\Response;
@@ -45,6 +48,7 @@ class DashboardController extends Controller
return Inertia::render('Clusters', [
'flux' => $fluxHealth->check(),
'clusters' => $this->clusters($currentTeam),
+ 'privateKeys' => $this->privateKeys($currentTeam),
'projects' => $projects,
'selectedProjectUuid' => $selectedProject['uuid'] ?? null,
'selectedEnvironmentUuid' => $selectedEnvironment['uuid'] ?? null,
@@ -98,9 +102,28 @@ class DashboardController extends Controller
Rule::unique('v5_clusters', 'name')->where('team_id', $currentTeam->id),
],
'description' => ['nullable', 'string', 'max:1000'],
+ 'wireguard_interface' => ['sometimes', 'string', 'max:32', 'regex:/^[a-zA-Z0-9_.-]+$/'],
+ 'wireguard_management_pool' => ['sometimes', 'string', 'max:64', $this->ipv4CidrRule()],
+ 'wireguard_listen_port' => ['sometimes', 'integer', 'min:1', 'max:65535'],
+ 'container_network_pool' => ['sometimes', 'string', 'max:64', $this->ipv4CidrRule()],
+ 'container_network_prefix' => ['sometimes', 'integer', 'min:1', 'max:32'],
+ 'namespaces' => ['sometimes', 'array', 'min:1'],
+ 'namespaces.*' => ['string', 'distinct', 'regex:/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/'],
+ 'default_deny_containers' => ['sometimes', 'boolean'],
+ 'coold_version' => ['sometimes', 'string', 'max:64'],
+ 'corrosion_version' => ['sometimes', 'string', 'max:64'],
+ 'corrosion_gossip_port' => ['sometimes', 'integer', 'min:1', 'max:65535'],
+ 'corrosion_api_port' => ['sometimes', 'integer', 'min:1', 'max:65535'],
+ 'builder_enabled' => ['sometimes', 'boolean'],
+ 'builder_capacity' => ['sometimes', 'integer', 'min:0', 'max:1000'],
+ 'builder_cpu_quota' => ['sometimes', 'string', 'max:32'],
+ 'builder_memory_max' => ['sometimes', 'string', 'max:32'],
+ 'builder_timeout_secs' => ['sometimes', 'integer', 'min:1', 'max:86400'],
]);
$cluster = V5Cluster::query()->create([
+ ...$this->defaultClusterConfiguration(),
+ ...collect($validated)->except(['name', 'description'])->all(),
'team_id' => $currentTeam->id,
'created_by_user_id' => $request->user()->id,
'name' => $validated['name'],
@@ -117,8 +140,587 @@ class DashboardController extends Controller
], 201);
}
+ public function bootstrapServer(Request $request, V5Cluster $cluster, V5Server $server): JsonResponse
+ {
+ $currentTeam = $request->attributes->get('v5.currentTeam');
+
+ if (
+ ! $currentTeam instanceof Team
+ || $cluster->team_id !== $currentTeam->id
+ || $server->team_id !== $currentTeam->id
+ || $server->cluster_id !== $cluster->id
+ ) {
+ abort(404);
+ }
+
+ if ($server->last_bootstrapped_at !== null) {
+ return response()->json([
+ 'message' => 'This server is already bootstrapped.',
+ ], 409);
+ }
+
+ $installedServers = $cluster->servers()
+ ->with('privateKey')
+ ->whereNotNull('last_bootstrapped_at')
+ ->orderBy('name')
+ ->get();
+ $action = $installedServers->isEmpty() ? 'bootstrap' : 'extend';
+ $server->load('privateKey');
+ $servers = $installedServers->toBase()
+ ->push($server)
+ ->unique('id')
+ ->values();
+
+ if ($servers->contains(fn (V5Server $server) => ! $server->privateKey instanceof PrivateKey)) {
+ return response()->json([
+ 'message' => 'The new server and every already-bootstrapped server in this cluster must have a private key before extending the cluster.',
+ ], 422);
+ }
+
+ $cluster->update([
+ 'last_cli_action' => $action,
+ 'last_cli_status' => 'running',
+ 'last_cli_summary' => "Starting Coolify CLI {$action} for {$server->name}...",
+ 'last_cli_ran_at' => now(),
+ ]);
+
+ $keyDirectory = storage_path('app/ssh/keys');
+ if (! is_dir($keyDirectory)) {
+ mkdir($keyDirectory, 0700, true);
+ }
+
+ $tempDirectory = $keyDirectory.'/v5_bootstrap_'.str()->random(16);
+ if (! mkdir($tempDirectory, 0700, true) && ! is_dir($tempDirectory)) {
+ $cluster->update([
+ 'last_cli_status' => 'failed',
+ 'last_cli_summary' => 'Could not create a temporary SSH configuration directory.',
+ 'last_cli_ran_at' => now(),
+ ]);
+
+ return response()->json([
+ 'cluster' => $this->freshSerializedCluster($cluster),
+ ], 500);
+ }
+
+ try {
+ $sshConfigLocation = $this->writeBootstrapSshConfig($servers, $tempDirectory);
+ $result = Process::timeout(max(60, (int) $cluster->builder_timeout_secs + 120))
+ ->run($this->bootstrapCommand($cluster, $servers, $server, $sshConfigLocation, $action));
+ $output = trim($result->output()."\n".$result->errorOutput());
+ $successful = $result->successful();
+ } catch (\Throwable $e) {
+ $output = $e->getMessage();
+ $successful = false;
+ } finally {
+ $this->deleteDirectory($tempDirectory);
+ }
+
+ $cluster->update([
+ 'last_cli_action' => $action,
+ 'last_cli_status' => $successful ? 'succeeded' : 'failed',
+ 'last_cli_summary' => str($output !== '' ? $output : 'No output returned.')->limit(20000)->toString(),
+ 'last_cli_ran_at' => now(),
+ ]);
+
+ if ($successful) {
+ $capabilities = collect($server->capabilities ?? [])
+ ->push('coold')
+ ->when($server->builder_enabled, fn ($capabilities) => $capabilities->push('builder'))
+ ->unique()
+ ->values()
+ ->all();
+
+ $server->update([
+ 'status' => 'installed',
+ 'capabilities' => $capabilities,
+ 'last_bootstrapped_at' => now(),
+ ]);
+ }
+
+ $payload = [
+ 'cluster' => $this->freshSerializedCluster($cluster),
+ ];
+
+ if (! $successful) {
+ $payload['message'] = $cluster->last_cli_summary;
+ }
+
+ return response()->json($payload, $successful ? 200 : 500);
+ }
+
+ public function storeServer(Request $request, V5Cluster $cluster): JsonResponse
+ {
+ $currentTeam = $request->attributes->get('v5.currentTeam');
+
+ if (! $currentTeam instanceof Team || $cluster->team_id !== $currentTeam->id) {
+ abort(403);
+ }
+
+ $validated = $request->validate([
+ 'name' => ['required', 'string', 'max:255'],
+ 'host' => [
+ 'required',
+ 'string',
+ 'max:255',
+ Rule::unique('v5_servers', 'host')
+ ->where('team_id', $currentTeam->id)
+ ->where('ssh_port', (int) $request->input('ssh_port', 22)),
+ ],
+ 'ssh_user' => ['required', 'string', 'max:255'],
+ 'ssh_port' => ['required', 'integer', 'min:1', 'max:65535'],
+ 'private_key_id' => [
+ 'required',
+ 'integer',
+ Rule::exists('private_keys', 'id')->where('team_id', $currentTeam->id),
+ ],
+ 'node_address' => ['nullable', 'string', 'max:255'],
+ 'builder_enabled' => ['sometimes', 'boolean'],
+ 'builder_capacity' => ['sometimes', 'integer', 'min:0', 'max:1000'],
+ 'builder_cpu_quota' => ['sometimes', 'string', 'max:32'],
+ 'wireguard_listen_port_override' => ['nullable', 'integer', 'min:1', 'max:65535'],
+ 'wireguard_endpoint_override' => ['nullable', 'string', 'max:255'],
+ ]);
+
+ $builderEnabled = (bool) ($validated['builder_enabled'] ?? $cluster->builder_enabled);
+ $builderCapacity = (int) ($validated['builder_capacity'] ?? $cluster->builder_capacity);
+ $builderCpuQuota = $validated['builder_cpu_quota'] ?? $cluster->builder_cpu_quota;
+ $devWireguardOverrides = $this->devLimaWireguardOverrides($validated['host'], (int) $validated['ssh_port']);
+
+ V5Server::query()->create([
+ 'team_id' => $currentTeam->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $request->user()->id,
+ 'name' => $validated['name'],
+ 'host' => $validated['host'],
+ 'ssh_user' => $validated['ssh_user'],
+ 'ssh_port' => $validated['ssh_port'],
+ 'private_key_id' => $validated['private_key_id'] ?? null,
+ 'status' => 'pending',
+ 'capabilities' => $builderEnabled ? ['coold', 'builder'] : ['coold'],
+ 'builder_enabled' => $builderEnabled,
+ 'builder_capacity' => $builderEnabled ? $builderCapacity : 0,
+ 'builder_cpu_quota' => $builderCpuQuota,
+ 'node_address' => $validated['node_address'] ?? $validated['host'],
+ 'wireguard_listen_port_override' => $validated['wireguard_listen_port_override'] ?? $devWireguardOverrides['listen_port'],
+ 'wireguard_endpoint_override' => $validated['wireguard_endpoint_override'] ?? $devWireguardOverrides['endpoint'],
+ ]);
+
+ $cluster->load(['servers' => fn ($query) => $query
+ ->with('privateKey')
+ ->orderBy('name')]);
+ $cluster->loadCount('servers');
+
+ return response()->json([
+ 'cluster' => $this->serializeCluster($cluster),
+ ], 201);
+ }
+
+ public function updateServer(Request $request, V5Cluster $cluster, V5Server $server): JsonResponse
+ {
+ $currentTeam = $request->attributes->get('v5.currentTeam');
+
+ if (
+ ! $currentTeam instanceof Team
+ || $cluster->team_id !== $currentTeam->id
+ || $server->team_id !== $currentTeam->id
+ || $server->cluster_id !== $cluster->id
+ ) {
+ abort(404);
+ }
+
+ $validated = $request->validate([
+ 'builder_enabled' => ['required', 'boolean'],
+ 'builder_capacity' => ['required', 'integer', 'min:0', 'max:1000'],
+ 'builder_cpu_quota' => ['required', 'string', 'max:32'],
+ ]);
+
+ $builderEnabled = (bool) $validated['builder_enabled'];
+ $capabilities = collect($server->capabilities ?? [])
+ ->push('coold')
+ ->when($builderEnabled, fn ($capabilities) => $capabilities->push('builder'))
+ ->when(! $builderEnabled, fn ($capabilities) => $capabilities->reject(fn (string $capability) => $capability === 'builder'))
+ ->unique()
+ ->values()
+ ->all();
+
+ $server->update([
+ 'capabilities' => $capabilities,
+ 'builder_enabled' => $builderEnabled,
+ 'builder_capacity' => $builderEnabled ? (int) $validated['builder_capacity'] : 0,
+ 'builder_cpu_quota' => $validated['builder_cpu_quota'],
+ ]);
+
+ $cluster->load(['servers' => fn ($query) => $query
+ ->with('privateKey')
+ ->orderBy('name')]);
+ $cluster->loadCount('servers');
+
+ return response()->json([
+ 'cluster' => $this->serializeCluster($cluster),
+ ]);
+ }
+
+ public function checkServer(Request $request, V5Cluster $cluster, V5Server $server): JsonResponse
+ {
+ $currentTeam = $request->attributes->get('v5.currentTeam');
+
+ if (
+ ! $currentTeam instanceof Team
+ || $cluster->team_id !== $currentTeam->id
+ || $server->team_id !== $currentTeam->id
+ || $server->cluster_id !== $cluster->id
+ ) {
+ abort(404);
+ }
+
+ if (! $server->privateKey instanceof PrivateKey) {
+ $server->update([
+ 'last_status_check' => 'failed',
+ 'last_status_output' => 'No private key is attached to this server.',
+ 'last_status_checked_at' => now(),
+ ]);
+
+ return response()->json([
+ 'cluster' => $this->freshSerializedCluster($cluster),
+ ]);
+ }
+
+ $keyDirectory = storage_path('app/ssh/keys');
+ if (! is_dir($keyDirectory)) {
+ mkdir($keyDirectory, 0700, true);
+ }
+
+ $keyLocation = tempnam($keyDirectory, 'v5_ssh_key_');
+ if ($keyLocation === false) {
+ $server->update([
+ 'last_status_check' => 'failed',
+ 'last_status_output' => 'Could not create a temporary SSH key file.',
+ 'last_status_checked_at' => now(),
+ ]);
+
+ return response()->json([
+ 'cluster' => $this->freshSerializedCluster($cluster),
+ ]);
+ }
+
+ file_put_contents($keyLocation, $server->privateKey->private_key);
+ chmod($keyLocation, 0600);
+
+ $target = "{$server->ssh_user}@{$server->host}";
+ $command = [
+ 'ssh',
+ '-o',
+ 'BatchMode=yes',
+ '-o',
+ 'LogLevel=ERROR',
+ '-o',
+ 'StrictHostKeyChecking=no',
+ '-o',
+ 'UserKnownHostsFile=/dev/null',
+ '-o',
+ 'ConnectTimeout=10',
+ '-o',
+ 'IdentitiesOnly=yes',
+ '-i',
+ $keyLocation,
+ '-p',
+ (string) $server->ssh_port,
+ $target,
+ "printf 'SSH connection OK\n'; hostname; uname -srm; command -v docker || true; command -v podman || true",
+ ];
+
+ try {
+ $result = Process::timeout(15)->run($command);
+ $output = trim($result->output()."\n".$result->errorOutput());
+ $status = $result->successful() ? 'reachable' : 'failed';
+ } catch (\Throwable $e) {
+ $output = $e->getMessage();
+ $status = 'failed';
+ } finally {
+ @unlink($keyLocation);
+ }
+
+ $server->update([
+ 'last_status_check' => $status,
+ 'last_status_output' => str($output !== '' ? $output : 'No output returned.')->limit(10000)->toString(),
+ 'last_status_checked_at' => now(),
+ ]);
+
+ return response()->json([
+ 'cluster' => $this->freshSerializedCluster($cluster),
+ ]);
+ }
+
+ public function destroyServer(Request $request, V5Cluster $cluster, V5Server $server): \Illuminate\Http\Response|JsonResponse
+ {
+ $currentTeam = $request->attributes->get('v5.currentTeam');
+
+ if (
+ ! $currentTeam instanceof Team
+ || $cluster->team_id !== $currentTeam->id
+ || $server->team_id !== $currentTeam->id
+ || $server->cluster_id !== $cluster->id
+ ) {
+ abort(404);
+ }
+
+ if ($server->last_bootstrapped_at !== null) {
+ return response()->json([
+ 'message' => 'Only unbootstrapped servers can be deleted.',
+ ], 409);
+ }
+
+ $server->delete();
+
+ return response()->json([
+ 'cluster' => $this->freshSerializedCluster($cluster),
+ ]);
+ }
+
+ public function destroyCluster(Request $request, V5Cluster $cluster): \Illuminate\Http\Response|JsonResponse
+ {
+ $currentTeam = $request->attributes->get('v5.currentTeam');
+
+ if (! $currentTeam instanceof Team || $cluster->team_id !== $currentTeam->id) {
+ abort(404);
+ }
+
+ if ($cluster->servers()->exists()) {
+ return response()->json([
+ 'message' => 'Only empty clusters can be deleted.',
+ ], 422);
+ }
+
+ $cluster->delete();
+
+ return response()->noContent();
+ }
+
+ /**
+ * @param Collection<int, V5Server> $servers
+ * @return array<int, string>
+ */
+ /**
+ * @return array{listen_port: int|null, endpoint: string|null}
+ */
+ private function devLimaWireguardOverrides(string $host, int $sshPort): array
+ {
+ if (! app()->environment(['local', 'development', 'testing']) || $host !== 'host.docker.internal') {
+ return ['listen_port' => null, 'endpoint' => null];
+ }
+
+ if ($sshPort < 60001 || $sshPort > 60009) {
+ return ['listen_port' => null, 'endpoint' => null];
+ }
+
+ $wireguardPort = $sshPort - 8180;
+
+ return [
+ 'listen_port' => $wireguardPort,
+ 'endpoint' => "host.lima.internal:{$wireguardPort}",
+ ];
+ }
+
+ private function bootstrapCommand(V5Cluster $cluster, Collection $servers, V5Server $newServer, string $sshConfigLocation, string $action): array
+ {
+ $command = [
+ $this->coolifyCliBin(),
+ 'init',
+ $action,
+ '--format',
+ 'table',
+ '--nodes',
+ $servers->map(fn (V5Server $server) => $this->bootstrapNode($server))->implode(','),
+ '--ssh-config',
+ $sshConfigLocation,
+ '--namespaces',
+ implode(',', $cluster->namespaces ?? V5Cluster::DEFAULT_NAMESPACES),
+ '--container-pool',
+ $cluster->container_network_pool,
+ '--container-prefix',
+ (string) $cluster->container_network_prefix,
+ '--wg-mgmt-pool',
+ $cluster->wireguard_management_pool,
+ '--wg-interface',
+ $cluster->wireguard_interface,
+ '--wg-listen-port',
+ (string) $cluster->wireguard_listen_port,
+ '--coold-version',
+ $cluster->coold_version,
+ '--corrosion-version',
+ $cluster->corrosion_version,
+ '--corrosion-gossip-port',
+ (string) $cluster->corrosion_gossip_port,
+ '--corrosion-api-port',
+ (string) $cluster->corrosion_api_port,
+ ];
+
+ if ($action === 'extend') {
+ array_push($command, '--new-nodes', $this->bootstrapNode($newServer));
+ }
+
+ $listenOverrides = $this->wireguardListenPortOverrides($servers);
+ if ($listenOverrides !== '') {
+ array_push($command, '--wg-listen-port-overrides', $listenOverrides);
+ }
+
+ $endpointOverrides = $this->wireguardEndpointOverrides($servers);
+ if ($endpointOverrides !== '') {
+ array_push($command, '--wg-endpoint-overrides', $endpointOverrides);
+ }
+
+ if (! $cluster->default_deny_containers) {
+ $command[] = '--skip-default-deny';
+ }
+
+ $builderServers = $servers->filter(fn (V5Server $server) => $server->builder_enabled);
+ if ($cluster->builder_enabled && $builderServers->isNotEmpty()) {
+ array_push(
+ $command,
+ '--enable-builder',
+ '--builder-hosts',
+ $builderServers
+ ->map(fn (V5Server $server) => $this->bootstrapNode($server))
+ ->implode(','),
+ '--builder-capacity',
+ (string) $cluster->builder_capacity,
+ '--builder-cpu-quota',
+ $cluster->builder_cpu_quota,
+ '--builder-memory-max',
+ $cluster->builder_memory_max,
+ '--builder-timeout-secs',
+ (string) $cluster->builder_timeout_secs,
+ );
+ }
+
+ $command[] = '--yes';
+
+ return $command;
+ }
+
+ private function coolifyCliBin(): string
+ {
+ $configuredBinary = (string) config('coold.coolify_cli_bin', '/usr/local/bin/coolify');
+ $devBinary = base_path('.dev/bin/coolify');
+
+ if ($configuredBinary === '/usr/local/bin/coolify' && $this->isRunnableDevelopmentCliBinary($devBinary)) {
+ return $devBinary;
+ }
+
+ return $configuredBinary;
+ }
+
+ private function isRunnableDevelopmentCliBinary(string $binary): bool
+ {
+ if (! is_file($binary)) {
+ return false;
+ }
+
+ $header = file_get_contents($binary, false, null, 0, 4);
+
+ if ($header === false) {
+ return false;
+ }
+
+ if (str_starts_with($header, '#!')) {
+ return true;
+ }
+
+ if ($header === "\x7FELF") {
+ return true;
+ }
+
+ return false;
+ }
+
+ private function bootstrapNode(V5Server $server): string
+ {
+ return "v5-server-{$server->id}";
+ }
+
+ /**
+ * @param Collection<int, V5Server> $servers
+ */
+ private function writeBootstrapSshConfig(Collection $servers, string $tempDirectory): string
+ {
+ $config = '';
+
+ $servers->each(function (V5Server $server) use (&$config, $tempDirectory): void {
+ $keyLocation = "{$tempDirectory}/server-{$server->id}.key";
+ file_put_contents($keyLocation, $server->privateKey->private_key);
+ chmod($keyLocation, 0600);
+
+ $config .= implode("\n", [
+ 'Host '.$this->bootstrapNode($server),
+ ' HostName '.$server->host,
+ ' Port '.$server->ssh_port,
+ ' User '.$server->ssh_user,
+ ' IdentityFile '.$keyLocation,
+ ' IdentitiesOnly yes',
+ ' LogLevel ERROR',
+ ' StrictHostKeyChecking no',
+ ' UserKnownHostsFile /dev/null',
+ ' BatchMode yes',
+ '',
+ ]);
+ });
+
+ $sshConfigLocation = "{$tempDirectory}/ssh.config";
+ file_put_contents($sshConfigLocation, $config);
+ chmod($sshConfigLocation, 0600);
+
+ return $sshConfigLocation;
+ }
+
+ private function deleteDirectory(string $directory): void
+ {
+ if (! is_dir($directory)) {
+ return;
+ }
+
+ foreach (scandir($directory) ?: [] as $file) {
+ if ($file === '.' || $file === '..') {
+ continue;
+ }
+
+ $path = "{$directory}/{$file}";
+
+ if (is_dir($path)) {
+ $this->deleteDirectory($path);
+
+ continue;
+ }
+
+ @unlink($path);
+ }
+
+ @rmdir($directory);
+ }
+
/**
- * @return array<int, array{id: string, name: string, description: string|null, serversCount: int, servers: array<int, array{id: string, name: string, host: string, sshUser: string, sshPort: int, status: string, capabilities: array<int, string>, builderEnabled: bool, builderCapacity: int, privateKeyName: string|null, lastBootstrappedAt: string|null}>}>
+ * @param Collection<int, V5Server> $servers
+ */
+ private function wireguardListenPortOverrides(Collection $servers): string
+ {
+ return $servers
+ ->filter(fn (V5Server $server) => $server->wireguard_listen_port_override !== null)
+ ->map(fn (V5Server $server) => $this->bootstrapNode($server).'='.$server->wireguard_listen_port_override)
+ ->implode(',');
+ }
+
+ /**
+ * @param Collection<int, V5Server> $servers
+ */
+ private function wireguardEndpointOverrides(Collection $servers): string
+ {
+ return $servers
+ ->filter(fn (V5Server $server) => $server->wireguard_endpoint_override !== null)
+ ->map(fn (V5Server $server) => $this->bootstrapNode($server).'='.$server->wireguard_endpoint_override)
+ ->implode(',');
+ }
+
+ /**
+ * @return array<int, array<string, mixed>>
*/
private function clusters(mixed $currentTeam): array
{
@@ -139,7 +741,28 @@ class DashboardController extends Controller
}
/**
- * @return array{id: string, name: string, description: string|null, serversCount: int, servers: array<int, array{id: string, name: string, host: string, sshUser: string, sshPort: int, status: string, capabilities: array<int, string>, builderEnabled: bool, builderCapacity: int, privateKeyName: string|null, lastBootstrappedAt: string|null}>}
+ * @return array<int, array{id: string, name: string}>
+ */
+ private function privateKeys(mixed $currentTeam): array
+ {
+ if (! $currentTeam instanceof Team) {
+ return [];
+ }
+
+ return PrivateKey::query()
+ ->where('team_id', $currentTeam->id)
+ ->where('is_git_related', false)
+ ->orderBy('name')
+ ->get(['id', 'name'])
+ ->map(fn (PrivateKey $privateKey) => [
+ 'id' => (string) $privateKey->id,
+ 'name' => $privateKey->name,
+ ])
+ ->all();
+ }
+
+ /**
+ * @return array<string, mixed>
*/
private function serializeCluster(V5Cluster $cluster): array
{
@@ -147,23 +770,111 @@ class DashboardController extends Controller
'id' => (string) $cluster->id,
'name' => $cluster->name,
'description' => $cluster->description,
+ 'wireguardInterface' => $cluster->wireguard_interface,
+ 'wireguardManagementPool' => $cluster->wireguard_management_pool,
+ 'wireguardListenPort' => $cluster->wireguard_listen_port,
+ 'containerNetworkPool' => $cluster->container_network_pool,
+ 'containerNetworkPrefix' => $cluster->container_network_prefix,
+ 'namespaces' => $cluster->namespaces ?? V5Cluster::DEFAULT_NAMESPACES,
+ 'defaultDenyContainers' => $cluster->default_deny_containers,
+ 'cooldVersion' => $cluster->coold_version,
+ 'corrosionVersion' => $cluster->corrosion_version,
+ 'corrosionGossipPort' => $cluster->corrosion_gossip_port,
+ 'corrosionApiPort' => $cluster->corrosion_api_port,
+ 'builderEnabled' => $cluster->builder_enabled,
+ 'builderCapacity' => $cluster->builder_capacity,
+ 'builderCpuQuota' => $cluster->builder_cpu_quota,
+ 'builderMemoryMax' => $cluster->builder_memory_max,
+ 'builderTimeoutSecs' => $cluster->builder_timeout_secs,
+ 'lastCliAction' => $cluster->last_cli_action,
+ 'lastCliStatus' => $cluster->last_cli_status,
+ 'lastCliSummary' => $cluster->last_cli_summary,
+ 'lastCliRanAt' => $cluster->last_cli_ran_at?->toJSON(),
'serversCount' => $cluster->servers_count ?? $cluster->servers->count(),
'servers' => $cluster->servers->map(fn (V5Server $server) => [
'id' => (string) $server->id,
'name' => $server->name,
'host' => $server->host,
- 'sshUser' => $server->ssh_user,
- 'sshPort' => $server->ssh_port,
'status' => $server->status,
'capabilities' => $server->capabilities ?? [],
'builderEnabled' => $server->builder_enabled,
'builderCapacity' => $server->builder_capacity,
+ 'builderCpuQuota' => $server->builder_cpu_quota,
+ 'nodeAddress' => $server->node_address,
+ 'wireguardListenPortOverride' => $server->wireguard_listen_port_override,
+ 'wireguardEndpointOverride' => $server->wireguard_endpoint_override,
+ 'wireguardManagementIp' => $server->wireguard_management_ip,
+ 'wireguardPublicKey' => $server->wireguard_public_key,
+ 'containerSubnets' => $server->container_subnets ?? [],
'privateKeyName' => $server->privateKey?->name,
'lastBootstrappedAt' => $server->last_bootstrapped_at?->toJSON(),
+ 'lastStatusCheck' => $server->last_status_check,
+ 'lastStatusOutput' => $server->last_status_output,
+ 'lastStatusCheckedAt' => $server->last_status_checked_at?->toJSON(),
])->all(),
];
}
+ /**
+ * @return array<string, mixed>
+ */
+ private function freshSerializedCluster(V5Cluster $cluster): array
+ {
+ $cluster->load(['servers' => fn ($query) => $query
+ ->with('privateKey')
+ ->orderBy('name')]);
+ $cluster->loadCount('servers');
+
+ return $this->serializeCluster($cluster);
+ }
+
+ /**
+ * @return array<string, mixed>
+ */
+ private function defaultClusterConfiguration(): array
+ {
+ return [
+ 'wireguard_interface' => V5Cluster::DEFAULT_WIREGUARD_INTERFACE,
+ 'wireguard_management_pool' => V5Cluster::DEFAULT_WIREGUARD_MANAGEMENT_POOL,
+ 'wireguard_listen_port' => V5Cluster::DEFAULT_WIREGUARD_LISTEN_PORT,
+ 'container_network_pool' => V5Cluster::DEFAULT_CONTAINER_NETWORK_POOL,
+ 'container_network_prefix' => V5Cluster::DEFAULT_CONTAINER_NETWORK_PREFIX,
+ 'namespaces' => V5Cluster::DEFAULT_NAMESPACES,
+ 'default_deny_containers' => true,
+ 'coold_version' => V5Cluster::DEFAULT_COOLD_VERSION,
+ 'corrosion_version' => V5Cluster::DEFAULT_CORROSION_VERSION,
+ 'corrosion_gossip_port' => V5Cluster::DEFAULT_CORROSION_GOSSIP_PORT,
+ 'corrosion_api_port' => V5Cluster::DEFAULT_CORROSION_API_PORT,
+ 'builder_enabled' => true,
+ 'builder_capacity' => V5Cluster::DEFAULT_BUILDER_CAPACITY,
+ 'builder_cpu_quota' => V5Cluster::DEFAULT_BUILDER_CPU_QUOTA,
+ 'builder_memory_max' => V5Cluster::DEFAULT_BUILDER_MEMORY_MAX,
+ 'builder_timeout_secs' => V5Cluster::DEFAULT_BUILDER_TIMEOUT_SECS,
+ ];
+ }
+
+ private function ipv4CidrRule(): \Closure
+ {
+ return function (string $attribute, mixed $value, \Closure $fail): void {
+ if (! is_string($value) || ! str_contains($value, '/')) {
+ $fail('The :attribute must be a valid IPv4 CIDR range.');
+
+ return;
+ }
+
+ [$ip, $prefix] = explode('/', $value, 2);
+
+ if (
+ filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false
+ || ! ctype_digit($prefix)
+ || (int) $prefix < 0
+ || (int) $prefix > 32
+ ) {
+ $fail('The :attribute must be a valid IPv4 CIDR range.');
+ }
+ };
+ }
+
/**
* @param array<int, array{uuid: string, name: string, environments: array<int, array{uuid: string, name: string}>}> $projects
* @return array{0: array{uuid: string, name: string, environments: array<int, array{uuid: string, name: string}>}|null, 1: array{uuid: string, name: string}|null}
diff --git a/app/Models/V5/Cluster.php b/app/Models/V5/Cluster.php
index 00fe981284..b5007d685e 100644
--- a/app/Models/V5/Cluster.php
+++ b/app/Models/V5/Cluster.php
@@ -11,13 +11,89 @@ class Cluster extends V5Model
{
protected $table = 'v5_clusters';
+ public const DEFAULT_WIREGUARD_INTERFACE = 'wg0';
+
+ public const DEFAULT_WIREGUARD_MANAGEMENT_POOL = '100.64.0.0/16';
+
+ public const DEFAULT_WIREGUARD_LISTEN_PORT = 51820;
+
+ public const DEFAULT_CONTAINER_NETWORK_POOL = '10.210.0.0/16';
+
+ public const DEFAULT_CONTAINER_NETWORK_PREFIX = 24;
+
+ public const DEFAULT_NAMESPACES = ['default'];
+
+ public const DEFAULT_COOLD_VERSION = 'nightly';
+
+ public const DEFAULT_CORROSION_VERSION = 'v1.0.0';
+
+ public const DEFAULT_CORROSION_GOSSIP_PORT = 8787;
+
+ public const DEFAULT_CORROSION_API_PORT = 8080;
+
+ public const DEFAULT_BUILDER_CAPACITY = 2;
+
+ public const DEFAULT_BUILDER_CPU_QUOTA = '200%';
+
+ public const DEFAULT_BUILDER_MEMORY_MAX = '2G';
+
+ public const DEFAULT_BUILDER_TIMEOUT_SECS = 1800;
+
protected $fillable = [
'team_id',
'created_by_user_id',
'name',
'description',
+ 'wireguard_interface',
+ 'wireguard_management_pool',
+ 'wireguard_listen_port',
+ 'container_network_pool',
+ 'container_network_prefix',
+ 'namespaces',
+ 'default_deny_containers',
+ 'coold_version',
+ 'corrosion_version',
+ 'corrosion_gossip_port',
+ 'corrosion_api_port',
+ 'builder_enabled',
+ 'builder_capacity',
+ 'builder_cpu_quota',
+ 'builder_memory_max',
+ 'builder_timeout_secs',
+ 'last_cli_action',
+ 'last_cli_status',
+ 'last_cli_summary',
+ 'last_cli_ran_at',
];
+ protected $attributes = [
+ 'wireguard_interface' => self::DEFAULT_WIREGUARD_INTERFACE,
+ 'wireguard_management_pool' => self::DEFAULT_WIREGUARD_MANAGEMENT_POOL,
+ 'wireguard_listen_port' => self::DEFAULT_WIREGUARD_LISTEN_PORT,
+ 'container_network_pool' => self::DEFAULT_CONTAINER_NETWORK_POOL,
+ 'container_network_prefix' => self::DEFAULT_CONTAINER_NETWORK_PREFIX,
+ 'default_deny_containers' => true,
+ 'coold_version' => self::DEFAULT_COOLD_VERSION,
+ 'corrosion_version' => self::DEFAULT_CORROSION_VERSION,
+ 'corrosion_gossip_port' => self::DEFAULT_CORROSION_GOSSIP_PORT,
+ 'corrosion_api_port' => self::DEFAULT_CORROSION_API_PORT,
+ 'builder_enabled' => true,
+ 'builder_capacity' => self::DEFAULT_BUILDER_CAPACITY,
+ 'builder_cpu_quota' => self::DEFAULT_BUILDER_CPU_QUOTA,
+ 'builder_memory_max' => self::DEFAULT_BUILDER_MEMORY_MAX,
+ 'builder_timeout_secs' => self::DEFAULT_BUILDER_TIMEOUT_SECS,
+ ];
+
+ protected function casts(): array
+ {
+ return [
+ 'namespaces' => 'array',
+ 'default_deny_containers' => 'boolean',
+ 'builder_enabled' => 'boolean',
+ 'last_cli_ran_at' => 'datetime',
+ ];
+ }
+
public function team(): BelongsTo
{
return $this->belongsTo(Team::class);
diff --git a/app/Models/V5/Server.php b/app/Models/V5/Server.php
index 619f9074d5..6b19103d64 100644
--- a/app/Models/V5/Server.php
+++ b/app/Models/V5/Server.php
@@ -24,7 +24,17 @@ class Server extends V5Model
'capabilities',
'builder_enabled',
'builder_capacity',
+ 'builder_cpu_quota',
+ 'node_address',
+ 'wireguard_listen_port_override',
+ 'wireguard_endpoint_override',
+ 'wireguard_management_ip',
+ 'wireguard_public_key',
+ 'container_subnets',
'last_bootstrapped_at',
+ 'last_status_check',
+ 'last_status_output',
+ 'last_status_checked_at',
];
protected function casts(): array
@@ -32,7 +42,9 @@ class Server extends V5Model
return [
'capabilities' => 'array',
'builder_enabled' => 'boolean',
+ 'container_subnets' => 'array',
'last_bootstrapped_at' => 'datetime',
+ 'last_status_checked_at' => 'datetime',
];
}
diff --git a/database/migrations/2026_06_16_204644_v5_add_wireguard_cli_configuration_to_clusters_and_servers.php b/database/migrations/2026_06_16_204644_v5_add_wireguard_cli_configuration_to_clusters_and_servers.php
new file mode 100644
index 0000000000..8ac987e002
--- /dev/null
+++ b/database/migrations/2026_06_16_204644_v5_add_wireguard_cli_configuration_to_clusters_and_servers.php
@@ -0,0 +1,90 @@
+<?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('v5_clusters', function (Blueprint $table) {
+ $table->string('wireguard_interface')->default('wg0')->after('description');
+ $table->string('wireguard_management_pool')->default('100.64.0.0/16')->after('wireguard_interface');
+ $table->unsignedInteger('wireguard_listen_port')->default(51820)->after('wireguard_management_pool');
+ $table->string('container_network_pool')->default('10.210.0.0/16')->after('wireguard_listen_port');
+ $table->unsignedTinyInteger('container_network_prefix')->default(24)->after('container_network_pool');
+ $table->json('namespaces')->nullable()->after('container_network_prefix');
+ $table->boolean('default_deny_containers')->default(true)->after('namespaces');
+ $table->string('coold_version')->default('nightly')->after('default_deny_containers');
+ $table->string('corrosion_version')->default('v1.0.0')->after('coold_version');
+ $table->unsignedInteger('corrosion_gossip_port')->default(8787)->after('corrosion_version');
+ $table->unsignedInteger('corrosion_api_port')->default(8080)->after('corrosion_gossip_port');
+ $table->boolean('builder_enabled')->default(true)->after('corrosion_api_port');
+ $table->unsignedInteger('builder_capacity')->default(2)->after('builder_enabled');
+ $table->string('builder_cpu_quota')->default('200%')->after('builder_capacity');
+ $table->string('builder_memory_max')->default('2G')->after('builder_cpu_quota');
+ $table->unsignedInteger('builder_timeout_secs')->default(1800)->after('builder_memory_max');
+ $table->string('last_cli_action')->nullable()->after('builder_timeout_secs');
+ $table->string('last_cli_status')->nullable()->after('last_cli_action');
+ $table->text('last_cli_summary')->nullable()->after('last_cli_status');
+ $table->timestamp('last_cli_ran_at')->nullable()->after('last_cli_summary');
+ });
+
+ Schema::table('v5_servers', function (Blueprint $table) {
+ $table->string('builder_cpu_quota')->default('200%')->after('builder_capacity');
+ $table->string('node_address')->nullable()->after('builder_cpu_quota');
+ $table->unsignedInteger('wireguard_listen_port_override')->nullable()->after('node_address');
+ $table->string('wireguard_endpoint_override')->nullable()->after('wireguard_listen_port_override');
+ $table->string('wireguard_management_ip')->nullable()->after('wireguard_endpoint_override');
+ $table->string('wireguard_public_key')->nullable()->after('wireguard_management_ip');
+ $table->json('container_subnets')->nullable()->after('wireguard_public_key');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('v5_servers', function (Blueprint $table) {
+ $table->dropColumn([
+ 'builder_cpu_quota',
+ 'node_address',
+ 'wireguard_listen_port_override',
+ 'wireguard_endpoint_override',
+ 'wireguard_management_ip',
+ 'wireguard_public_key',
+ 'container_subnets',
+ ]);
+ });
+
+ Schema::table('v5_clusters', function (Blueprint $table) {
+ $table->dropColumn([
+ 'wireguard_interface',
+ 'wireguard_management_pool',
+ 'wireguard_listen_port',
+ 'container_network_pool',
+ 'container_network_prefix',
+ 'namespaces',
+ 'default_deny_containers',
+ 'coold_version',
+ 'corrosion_version',
+ 'corrosion_gossip_port',
+ 'corrosion_api_port',
+ 'builder_enabled',
+ 'builder_capacity',
+ 'builder_cpu_quota',
+ 'builder_memory_max',
+ 'builder_timeout_secs',
+ 'last_cli_action',
+ 'last_cli_status',
+ 'last_cli_summary',
+ 'last_cli_ran_at',
+ ]);
+ });
+ }
+};
diff --git a/database/migrations/2026_06_17_165112_v5_add_builder_cpu_quota_to_servers_table.php b/database/migrations/2026_06_17_165112_v5_add_builder_cpu_quota_to_servers_table.php
new file mode 100644
index 0000000000..a07d18d8af
--- /dev/null
+++ b/database/migrations/2026_06_17_165112_v5_add_builder_cpu_quota_to_servers_table.php
@@ -0,0 +1,36 @@
+<?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
+ {
+ if (Schema::hasColumn('v5_servers', 'builder_cpu_quota')) {
+ return;
+ }
+
+ Schema::table('v5_servers', function (Blueprint $table) {
+ $table->string('builder_cpu_quota')->default('200%')->after('builder_capacity');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ if (! Schema::hasColumn('v5_servers', 'builder_cpu_quota')) {
+ return;
+ }
+
+ Schema::table('v5_servers', function (Blueprint $table) {
+ $table->dropColumn('builder_cpu_quota');
+ });
+ }
+};
diff --git a/database/migrations/2026_06_17_172845_add_status_check_fields_to_v5_servers_table.php b/database/migrations/2026_06_17_172845_add_status_check_fields_to_v5_servers_table.php
new file mode 100644
index 0000000000..76dd8f2c2d
--- /dev/null
+++ b/database/migrations/2026_06_17_172845_add_status_check_fields_to_v5_servers_table.php
@@ -0,0 +1,34 @@
+<?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('v5_servers', function (Blueprint $table) {
+ $table->string('last_status_check')->nullable()->after('last_bootstrapped_at');
+ $table->text('last_status_output')->nullable()->after('last_status_check');
+ $table->timestamp('last_status_checked_at')->nullable()->after('last_status_output');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('v5_servers', function (Blueprint $table) {
+ $table->dropColumn([
+ 'last_status_check',
+ 'last_status_output',
+ 'last_status_checked_at',
+ ]);
+ });
+ }
+};
diff --git a/database/schema/testing-schema.sql b/database/schema/testing-schema.sql
index 289b4df2a9..c2fde927e8 100644
--- a/database/schema/testing-schema.sql
+++ b/database/schema/testing-schema.sql
@@ -1327,6 +1327,26 @@ CREATE TABLE IF NOT EXISTS "v5_clusters" (
"created_by_user_id" INTEGER NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
+ "wireguard_interface" TEXT DEFAULT 'wg0' NOT NULL,
+ "wireguard_management_pool" TEXT DEFAULT '100.64.0.0/16' NOT NULL,
+ "wireguard_listen_port" INTEGER DEFAULT '51820' NOT NULL,
+ "container_network_pool" TEXT DEFAULT '10.210.0.0/16' NOT NULL,
+ "container_network_prefix" INTEGER DEFAULT '24' NOT NULL,
+ "namespaces" JSON,
+ "default_deny_containers" INTEGER DEFAULT true NOT NULL,
+ "coold_version" TEXT DEFAULT 'nightly' NOT NULL,
+ "corrosion_version" TEXT DEFAULT 'v1.0.0' NOT NULL,
+ "corrosion_gossip_port" INTEGER DEFAULT '8787' NOT NULL,
+ "corrosion_api_port" INTEGER DEFAULT '8080' NOT NULL,
+ "builder_enabled" INTEGER DEFAULT true NOT NULL,
+ "builder_capacity" INTEGER DEFAULT '2' NOT NULL,
+ "builder_cpu_quota" TEXT DEFAULT '200%' NOT NULL,
+ "builder_memory_max" TEXT DEFAULT '2G' NOT NULL,
+ "builder_timeout_secs" INTEGER NOT NULL DEFAULT '1800',
+ "last_cli_action" TEXT,
+ "last_cli_status" TEXT,
+ "last_cli_summary" TEXT,
+ "last_cli_ran_at" TEXT,
"created_at" TEXT,
"updated_at" TEXT
);
@@ -1345,7 +1365,17 @@ CREATE TABLE IF NOT EXISTS "v5_servers" (
"capabilities" TEXT,
"builder_enabled" INTEGER DEFAULT false NOT NULL,
"builder_capacity" INTEGER DEFAULT '0' NOT NULL,
+ "builder_cpu_quota" TEXT DEFAULT '200%' NOT NULL,
+ "node_address" TEXT,
+ "wireguard_listen_port_override" INTEGER,
+ "wireguard_endpoint_override" TEXT,
+ "wireguard_management_ip" TEXT,
+ "wireguard_public_key" TEXT,
+ "container_subnets" JSON,
"last_bootstrapped_at" TEXT,
+ "last_status_check" TEXT,
+ "last_status_output" TEXT,
+ "last_status_checked_at" TEXT,
"created_at" TEXT,
"updated_at" TEXT
);
@@ -1783,3 +1813,6 @@ INSERT INTO "migrations" ("id", "migration", "batch") VALUES (313, '2025_12_17_0
INSERT INTO "migrations" ("id", "migration", "batch") VALUES (314, '2025_12_17_000002_add_restart_tracking_to_standalone_databases', 314);
INSERT INTO "migrations" ("id", "migration", "batch") VALUES (316, '2026_06_16_130650_v5_create_servers_table', 316);
INSERT INTO "migrations" ("id", "migration", "batch") VALUES (317, '2026_06_16_130649_v5_create_clusters_table', 317);
+INSERT INTO "migrations" ("id", "migration", "batch") VALUES (318, '2026_06_16_204644_v5_add_wireguard_cli_configuration_to_clusters_and_servers', 318);
+INSERT INTO "migrations" ("id", "migration", "batch") VALUES (319, '2026_06_17_165112_v5_add_builder_cpu_quota_to_servers_table', 319);
+INSERT INTO "migrations" ("id", "migration", "batch") VALUES (320, '2026_06_17_172845_add_status_check_fields_to_v5_servers_table', 320);
diff --git a/database/seeders/V5DevLimaSeeder.php b/database/seeders/V5DevLimaSeeder.php
index 1151f8fb3c..ea796622d8 100644
--- a/database/seeders/V5DevLimaSeeder.php
+++ b/database/seeders/V5DevLimaSeeder.php
@@ -59,26 +59,32 @@ class V5DevLimaSeeder extends Seeder
'capabilities' => $capabilities,
'builder_enabled' => $builderEnabled,
'builder_capacity' => $builderCapacity,
+ 'wireguard_listen_port_override' => $server['wireguard_listen_port_override'],
+ 'wireguard_endpoint_override' => $server['wireguard_endpoint_override'],
'last_bootstrapped_at' => now(),
]);
}
}
/**
- * @return array<int, array{name: string, host: string, ssh_port: int}>
+ * @return array<int, array{name: string, host: string, ssh_port: int, wireguard_listen_port_override: int, wireguard_endpoint_override: string}>
*/
private function servers(): array
{
return [
[
'name' => 'coold-dev',
- 'host' => 'lima-coold-dev',
- 'ssh_port' => 22,
+ 'host' => 'host.docker.internal',
+ 'ssh_port' => 60001,
+ 'wireguard_listen_port_override' => 51821,
+ 'wireguard_endpoint_override' => 'host.lima.internal:51821',
],
[
'name' => 'coold-dev-2',
- 'host' => 'lima-coold-dev-2',
- 'ssh_port' => 22,
+ 'host' => 'host.docker.internal',
+ 'ssh_port' => 60002,
+ 'wireguard_listen_port_override' => 51822,
+ 'wireguard_endpoint_override' => 'host.lima.internal:51822',
],
];
}
diff --git a/dev/lima/coold.yaml b/dev/lima/coold.yaml
index 4629d61cce..327d1589c1 100644
--- a/dev/lima/coold.yaml
+++ b/dev/lima/coold.yaml
@@ -13,6 +13,9 @@ containerd:
system: false
user: false
+ssh:
+ localPort: {{COOLIFY_COOLD_VM_SSH_PORT}}
+
images:
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
@@ -58,4 +61,19 @@ provision:
mkdir -p /etc/coolify /var/lib/coolify-dev
chmod 755 /etc/coolify
+ coolify_test_public_key="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuGmoeGq/pojrsyP1pszcNVuZx9iFkCELtxrh31QJ68 sail@76ff66d2e2dd"
+ install -d -m 700 /root/.ssh
+ touch /root/.ssh/authorized_keys
+ grep -qxF "$coolify_test_public_key" /root/.ssh/authorized_keys || echo "$coolify_test_public_key" >>/root/.ssh/authorized_keys
+ chmod 600 /root/.ssh/authorized_keys
+ target_home="$(getent passwd 501 | cut -d: -f6 || true)"
+ if [ -n "$target_home" ] && [ -d "$target_home" ]; then
+ owner="$(stat -c '%u:%g' "$target_home")"
+ install -d -m 700 -o "${owner%:*}" -g "${owner#*:}" "$target_home/.ssh"
+ touch "$target_home/.ssh/authorized_keys"
+ grep -qxF "$coolify_test_public_key" "$target_home/.ssh/authorized_keys" || echo "$coolify_test_public_key" >>"$target_home/.ssh/authorized_keys"
+ chown "$owner" "$target_home/.ssh/authorized_keys"
+ chmod 600 "$target_home/.ssh/authorized_keys"
+ fi
+
echo "[coold-vm] Minimal provisioning complete. coolify bootstrap will install WireGuard, Podman, Corrosion, coold, and builder."
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 83dfad68d4..6cfa907236 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -19,6 +19,7 @@ services:
COOLIFY_COOLD_VERSION: "${COOLIFY_COOLD_VERSION:-nightly}"
COOLIFY_FLUX_VERSION: "${COOLIFY_FLUX_VERSION:-nightly}"
COOLIFY_CLI_VERSION: "${COOLIFY_CLI_VERSION:-nightly}"
+ COOLIFY_CLI_SSH_USER: "${COOLIFY_CLI_SSH_USER:-}"
COOLIFY_CORROSION_VERSION: "${COOLIFY_CORROSION_VERSION:-v1.0.0}"
PUSHER_HOST: "${PUSHER_HOST:-}"
PUSHER_PORT: "${PUSHER_PORT:-}"
diff --git a/resources/css/app.css b/resources/css/app.css
index de92bf0c90..a4f42149d2 100644
--- a/resources/css/app.css
+++ b/resources/css/app.css
@@ -105,6 +105,14 @@ body {
@apply w-full min-h-full bg-gray-50 dark:bg-base dark:text-neutral-400;
}
+@media (max-width: 767px) {
+ input,
+ textarea,
+ select {
+ font-size: 16px;
+ }
+}
+
body {
@apply min-h-screen text-sm font-sans antialiased scrollbar overflow-x-hidden;
}
diff --git a/resources/css/v5/app.css b/resources/css/v5/app.css
index 1f85d69583..e1637b694d 100644
--- a/resources/css/v5/app.css
+++ b/resources/css/v5/app.css
@@ -152,6 +152,14 @@
@apply font-sans;
}
+ @media (max-width: 767px) {
+ input,
+ textarea,
+ select {
+ font-size: 16px;
+ }
+ }
+
body {
@apply bg-background text-foreground;
min-height: 100vh;
diff --git a/resources/js/v5/Pages/Clusters.tsx b/resources/js/v5/Pages/Clusters.tsx
index 26f5f9a4e2..a564b710eb 100644
--- a/resources/js/v5/Pages/Clusters.tsx
+++ b/resources/js/v5/Pages/Clusters.tsx
@@ -4,9 +4,11 @@ import type { FormEvent } from 'react';
import { AppNavbar } from '@/components/app-navbar';
import { Button } from '@/components/ui/button';
+import { Field, FieldError, FieldLabel } from '@/components/ui/field';
+import { Input } from '@/components/ui/input';
+import { Textarea } from '@/components/ui/textarea';
import {
Dialog,
- DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
@@ -14,17 +16,88 @@ import {
DialogTitle,
} from '@/components/ui/dialog';
import { csrfToken } from '@/lib/csrf';
-import type { V5Cluster, V5DashboardProps } from '@/types';
+import { usePendingIds } from '@/lib/use-pending-ids';
+import type { V5Cluster, V5DashboardProps, V5Server } from '@/types';
type ClusterFormErrors = {
name?: string[];
description?: string[];
+ wireguard_interface?: string[];
+ wireguard_management_pool?: string[];
+ wireguard_listen_port?: string[];
+ container_network_pool?: string[];
+ container_network_prefix?: string[];
+ namespaces?: string[];
+ default_deny_containers?: string[];
+ coold_version?: string[];
+ corrosion_version?: string[];
+ corrosion_gossip_port?: string[];
+ corrosion_api_port?: string[];
+ builder_enabled?: string[];
+ builder_capacity?: string[];
+ builder_cpu_quota?: string[];
+ builder_memory_max?: string[];
+ builder_timeout_secs?: string[];
};
type StoreClusterResponse = {
cluster: V5Cluster;
};
+type ServerFormErrors = {
+ name?: string[];
+ host?: string[];
+ ssh_user?: string[];
+ ssh_port?: string[];
+ private_key_id?: string[];
+ node_address?: string[];
+ builder_enabled?: string[];
+ builder_capacity?: string[];
+ builder_cpu_quota?: string[];
+ wireguard_listen_port_override?: string[];
+ wireguard_endpoint_override?: string[];
+};
+
+type StoreServerResponse = {
+ cluster: V5Cluster;
+};
+
+type UpdateServerResponse = {
+ cluster: V5Cluster;
+};
+
+type CheckServerResponse = {
+ cluster: V5Cluster;
+};
+
+type DeleteServerResponse = {
+ cluster: V5Cluster;
+};
+
+type BootstrapServerResponse = {
+ cluster?: V5Cluster;
+ message?: string;
+};
+
+const clusterDefaults = {
+ wireguardInterface: 'wg0',
+ wireguardManagementPool: '100.64.0.0/16',
+ wireguardListenPort: '51820',
+ containerNetworkPool: '10.210.0.0/16',
+ containerNetworkPrefix: '24',
+ namespaces: 'default',
+ defaultDenyContainers: true,
+ cooldVersion: 'nightly',
+ corrosionVersion: 'v1.0.0',
+ corrosionGossipPort: '8787',
+ corrosionApiPort: '8080',
+ builderEnabled: true,
+ builderCapacity: '2',
+ builderCpuQuota: '200%',
+ builderMemoryMax: '2G',
+ builderTimeoutSecs: '1800',
+};
+
function formatDate(value: string | null): string {
if (value === null) {
return 'Never';
@@ -47,6 +120,7 @@ function normalizeCapabilities(capabilities: string[]): string {
export default function Clusters({
flux,
clusters = [],
+ privateKeys = [],
projects = [],
selectedProjectUuid = null,
selectedEnvironmentUuid = null,
@@ -55,9 +129,57 @@ export default function Clusters({
const [selectedClusterId, setSelectedClusterId] = useState<string>(clusters[0]?.id ?? '');
const [name, setName] = useState('');
const [description, setDescription] = useState('');
+ const [wireguardInterface, setWireguardInterface] = useState(clusterDefaults.wireguardInterface);
+ const [wireguardManagementPool, setWireguardManagementPool] = useState(clusterDefaults.wireguardManagementPool);
+ const [wireguardListenPort, setWireguardListenPort] = useState(clusterDefaults.wireguardListenPort);
+ const [containerNetworkPool, setContainerNetworkPool] = useState(clusterDefaults.containerNetworkPool);
+ const [containerNetworkPrefix, setContainerNetworkPrefix] = useState(clusterDefaults.containerNetworkPrefix);
+ const [namespaces, setNamespaces] = useState(clusterDefaults.namespaces);
+ const [defaultDenyContainers, setDefaultDenyContainers] = useState(clusterDefaults.defaultDenyContainers);
+ const [cooldVersion, setCooldVersion] = useState(clusterDefaults.cooldVersion);
+ const [corrosionVersion, setCorrosionVersion] = useState(clusterDefaults.corrosionVersion);
+ const [corrosionGossipPort, setCorrosionGossipPort] = useState(clusterDefaults.corrosionGossipPort);
+ const [corrosionApiPort, setCorrosionApiPort] = useState(clusterDefaults.corrosionApiPort);
+ const [builderEnabled, setBuilderEnabled] = useState(clusterDefaults.builderEnabled);
+ const [builderCapacity, setBuilderCapacity] = useState(clusterDefaults.builderCapacity);
+ const [builderCpuQuota, setBuilderCpuQuota] = useState(clusterDefaults.builderCpuQuota);
+ const [builderMemoryMax, setBuilderMemoryMax] = useState(clusterDefaults.builderMemoryMax);
+ const [builderTimeoutSecs, setBuilderTimeoutSecs] = useState(clusterDefaults.builderTimeoutSecs);
const [errors, setErrors] = useState<ClusterFormErrors>({});
+ const [serverName, setServerName] = useState('');
+ const [serverHost, setServerHost] = useState('');
+ const [serverSshUser, setServerSshUser] = useState('root');
+ const [serverSshPort, setServerSshPort] = useState('22');
+ const [selectedPrivateKeyId, setSelectedPrivateKeyId] = useState('');
+ const [serverNodeAddress, setServerNodeAddress] = useState('');
+ const [serverBuilderEnabled, setServerBuilderEnabled] = useState(true);
+ const [serverBuilderCapacity, setServerBuilderCapacity] = useState('2');
+ const [serverBuilderCpuQuota, setServerBuilderCpuQuota] = useState(clusterDefaults.builderCpuQuota);
+ const [wireguardListenPortOverride, setWireguardListenPortOverride] = useState('');
+ const [wireguardEndpointOverride, setWireguardEndpointOverride] = useState('');
+ const [serverErrors, setServerErrors] = useState<ServerFormErrors>({});
+ const [editingServer, setEditingServer] = useState<V5Server | null>(null);
+ const [editServerBuilderEnabled, setEditServerBuilderEnabled] = useState(true);
+ const [editServerBuilderCapacity, setEditServerBuilderCapacity] = useState('2');
+ const [editServerBuilderCpuQuota, setEditServerBuilderCpuQuota] = useState(clusterDefaults.builderCpuQuota);
+ const [editServerErrors, setEditServerErrors] = useState<ServerFormErrors>({});
const [isSubmitting, setIsSubmitting] = useState(false);
+ const [isServerSubmitting, setIsServerSubmitting] = useState(false);
+ const [isServerUpdateSubmitting, setIsServerUpdateSubmitting] = useState(false);
+ const checkingServers = usePendingIds<string>();
+ const bootstrappingServers = usePendingIds<string>();
+ const [bootstrapServerError, setBootstrapServerError] = useState<string | null>(null);
+ const deletingServers = usePendingIds<string>();
+ const [isDeletingCluster, setIsDeletingCluster] = useState(false);
+ const [deleteClusterError, setDeleteClusterError] = useState<string | null>(null);
+ const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
+ const [clusterPendingDelete, setClusterPendingDelete] = useState<V5Cluster | null>(null);
+ const [serverPendingDelete, setServerPendingDelete] = useState<V5Server | null>(null);
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
+ const [isAddServerDialogOpen, setIsAddServerDialogOpen] = useState(false);
+ const [isEditServerDialogOpen, setIsEditServerDialogOpen] = useState(false);
+ const [showAdvancedConfiguration, setShowAdvancedConfiguration] = useState(false);
+ const [showAdvancedServerConfiguration, setShowAdvancedServerConfiguration] = useState(false);
const selectedCluster = useMemo(
() => clusterList.find((cluster) => cluster.id === selectedClusterId) ?? clusterList[0] ?? null,
@@ -80,11 +202,32 @@ export default function Clusters({
body: JSON.stringify({
name,
description: description.trim() === '' ? null : description,
+ wireguard_interface: wireguardInterface,
+ wireguard_management_pool: wireguardManagementPool,
+ wireguard_listen_port: Number(wireguardListenPort),
+ container_network_pool: containerNetworkPool,
+ container_network_prefix: Number(containerNetworkPrefix),
+ namespaces: namespaces
+ .split(',')
+ .map((namespace) => namespace.trim())
+ .filter(Boolean),
+ default_deny_containers: defaultDenyContainers,
+ coold_version: cooldVersion,
+ corrosion_version: corrosionVersion,
+ corrosion_gossip_port: Number(corrosionGossipPort),
+ corrosion_api_port: Number(corrosionApiPort),
+ builder_enabled: builderEnabled,
+ builder_capacity: Number(builderCapacity),
+ builder_cpu_quota: builderCpuQuota,
+ builder_memory_max: builderMemoryMax,
+ builder_timeout_secs: Number(builderTimeoutSecs),
}),
});
if (response.status === 422) {
- const payload = (await response.json()) as { errors?: ClusterFormErrors };
+ const payload = (await response.json()) as {
+ errors?: ClusterFormErrors;
+ };
setErrors(payload.errors ?? {});
setIsSubmitting(false);
@@ -101,21 +244,367 @@ export default function Clusters({
}
const payload = (await response.json()) as StoreClusterResponse;
- const nextClusters = [...clusterList, payload.cluster].sort((first, second) => first.name.localeCompare(second.name));
+ const nextClusters = [...clusterList, payload.cluster].sort((first, second) =>
+ first.name.localeCompare(second.name),
+ );
setClusterList(nextClusters);
setSelectedClusterId(payload.cluster.id);
setName('');
setDescription('');
+ resetAdvancedConfiguration();
setIsCreateDialogOpen(false);
setIsSubmitting(false);
}
+ async function createServer(event: FormEvent<HTMLFormElement>): Promise<void> {
+ event.preventDefault();
+
+ if (!selectedCluster) {
+ return;
+ }
+
+ setIsServerSubmitting(true);
+ setServerErrors({});
+
+ const response = await fetch(`/v5/clusters/${selectedCluster.id}/servers`, {
+ method: 'POST',
+ credentials: 'same-origin',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-CSRF-TOKEN': csrfToken(),
+ },
+ body: JSON.stringify({
+ name: serverName,
+ host: serverHost,
+ ssh_user: serverSshUser,
+ ssh_port: Number(serverSshPort),
+ private_key_id: selectedPrivateKeyId === '' ? null : Number(selectedPrivateKeyId),
+ node_address: serverNodeAddress.trim() === '' ? null : serverNodeAddress,
+ builder_enabled: serverBuilderEnabled,
+ builder_capacity: Number(serverBuilderCapacity),
+ builder_cpu_quota: serverBuilderCpuQuota,
+ wireguard_listen_port_override:
+ wireguardListenPortOverride.trim() === '' ? null : Number(wireguardListenPortOverride),
+ wireguard_endpoint_override: wireguardEndpointOverride.trim() === '' ? null : wireguardEndpointOverride,
+ }),
+ });
+
+ if (response.status === 422) {
+ const payload = (await response.json()) as {
+ errors?: ServerFormErrors;
+ };
+ setServerErrors(payload.errors ?? {});
+ setIsServerSubmitting(false);
+
+ return;
+ }
+
+ if (!response.ok) {
+ setServerErrors({
+ name: ['Unable to add this server. Please try again.'],
+ });
+ setIsServerSubmitting(false);
+
+ return;
+ }
+
+ const payload = (await response.json()) as StoreServerResponse;
+
+ setClusterList((currentClusters) =>
+ currentClusters.map((cluster) => (cluster.id === payload.cluster.id ? payload.cluster : cluster)),
+ );
+ resetServerForm();
+ setIsAddServerDialogOpen(false);
+ setIsServerSubmitting(false);
+ }
+
+ async function updateServer(event: FormEvent<HTMLFormElement>): Promise<void> {
+ event.preventDefault();
+
+ if (!selectedCluster || !editingServer) {
+ return;
+ }
+
+ setIsServerUpdateSubmitting(true);
+ setEditServerErrors({});
+
+ const response = await fetch(`/v5/clusters/${selectedCluster.id}/servers/${editingServer.id}`, {
+ method: 'PATCH',
+ credentials: 'same-origin',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-CSRF-TOKEN': csrfToken(),
+ },
+ body: JSON.stringify({
+ builder_enabled: editServerBuilderEnabled,
+ builder_capacity: Number(editServerBuilderCapacity),
+ builder_cpu_quota: editServerBuilderCpuQuota,
+ }),
+ });
+
+ if (response.status === 422) {
+ const payload = (await response.json()) as {
+ errors?: ServerFormErrors;
+ };
+ setEditServerErrors(payload.errors ?? {});
+ setIsServerUpdateSubmitting(false);
+
+ return;
+ }
+
+ if (!response.ok) {
+ setEditServerErrors({
+ builder_capacity: ['Unable to update this server. Please try again.'],
+ });
+ setIsServerUpdateSubmitting(false);
+
+ return;
+ }
+
+ const payload = (await response.json()) as UpdateServerResponse;
+
+ setClusterList((currentClusters) =>
+ currentClusters.map((cluster) => (cluster.id === payload.cluster.id ? payload.cluster : cluster)),
+ );
+ resetEditServerForm();
+ setIsEditServerDialogOpen(false);
+ setIsServerUpdateSubmitting(false);
+ }
+
+ async function checkServer(server: V5Server): Promise<void> {
+ if (!selectedCluster) {
+ return;
+ }
+
+ checkingServers.start(server.id);
+
+ const response = await fetch(`/v5/clusters/${selectedCluster.id}/servers/${server.id}/check`, {
+ method: 'POST',
+ credentials: 'same-origin',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-CSRF-TOKEN': csrfToken(),
+ },
+ });
+
+ if (response.ok) {
+ const payload = (await response.json()) as CheckServerResponse;
+
+ setClusterList((currentClusters) =>
+ currentClusters.map((cluster) => (cluster.id === payload.cluster.id ? payload.cluster : cluster)),
+ );
+ }
+
+ checkingServers.finish(server.id);
+ }
+
+ async function bootstrapServer(server: V5Server): Promise<void> {
+ if (!selectedCluster) {
+ return;
+ }
+
+ bootstrappingServers.start(server.id);
+ setBootstrapServerError(null);
+
+ const response = await fetch(`/v5/clusters/${selectedCluster.id}/servers/${server.id}/bootstrap`, {
+ method: 'POST',
+ credentials: 'same-origin',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-CSRF-TOKEN': csrfToken(),
+ },
+ });
+ const payload = (await response.json()) as BootstrapServerResponse;
+
+ if (payload.cluster) {
+ setClusterList((currentClusters) =>
+ currentClusters.map((cluster) => (cluster.id === payload.cluster?.id ? payload.cluster : cluster)),
+ );
+ }
+
+ if (!response.ok) {
+ setBootstrapServerError(payload.message ?? 'Unable to bootstrap this server. Check the CLI state output.');
+ }
+
+ bootstrappingServers.finish(server.id);
+ }
+
+ function openDeleteClusterDialog(): void {
+ if (!selectedCluster || selectedCluster.serversCount !== 0) {
+ setDeleteClusterError('Only empty clusters can be deleted.');
+
+ return;
+ }
+
+ setDeleteClusterError(null);
+ setClusterPendingDelete(selectedCluster);
+ setServerPendingDelete(null);
+ setIsDeleteDialogOpen(true);
+ }
+
+ function openDeleteServerDialog(server: V5Server): void {
+ if (!selectedCluster || server.lastBootstrappedAt !== null) {
+ return;
+ }
+
+ setDeleteClusterError(null);
+ setClusterPendingDelete(selectedCluster);
+ setServerPendingDelete(server);
+ setIsDeleteDialogOpen(true);
+ }
+
+ async function deleteUnbootstrappedServer(cluster: V5Cluster, server: V5Server): Promise<void> {
+ if (server.lastBootstrappedAt !== null) {
+ return;
+ }
+
+ deletingServers.start(server.id);
+
+ const response = await fetch(`/v5/clusters/${cluster.id}/servers/${server.id}`, {
+ method: 'DELETE',
+ credentials: 'same-origin',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-CSRF-TOKEN': csrfToken(),
+ },
+ });
+
+ if (response.ok) {
+ const payload = (await response.json()) as DeleteServerResponse;
+
+ setClusterList((currentClusters) =>
+ currentClusters.map((cluster) => (cluster.id === payload.cluster.id ? payload.cluster : cluster)),
+ );
+ }
+
+ deletingServers.finish(server.id);
+ setIsDeleteDialogOpen(false);
+ setClusterPendingDelete(null);
+ setServerPendingDelete(null);
+ }
+
+ function openEditServerDialog(server: V5Server): void {
+ setEditingServer(server);
+ setEditServerBuilderEnabled(server.builderEnabled);
+ setEditServerBuilderCapacity(String(server.builderCapacity));
+ setEditServerBuilderCpuQuota(server.builderCpuQuota);
+ setEditServerErrors({});
+ setIsEditServerDialogOpen(true);
+ }
+
+ async function deleteCluster(cluster: V5Cluster): Promise<void> {
+ if (cluster.serversCount !== 0) {
+ setDeleteClusterError('Only empty clusters can be deleted.');
+
+ return;
+ }
+
+ setIsDeletingCluster(true);
+ setDeleteClusterError(null);
+
+ const response = await fetch(`/v5/clusters/${cluster.id}`, {
+ method: 'DELETE',
+ credentials: 'same-origin',
+ headers: {
+ Accept: 'application/json',
+ 'X-CSRF-TOKEN': csrfToken(),
+ },
+ });
+
+ if (response.status === 422) {
+ const payload = (await response.json()) as { message?: string };
+ setDeleteClusterError(payload.message ?? 'Only empty clusters can be deleted.');
+ setIsDeletingCluster(false);
+
+ return;
+ }
+
+ if (!response.ok) {
+ setDeleteClusterError('Unable to delete this cluster. Please try again.');
+ setIsDeletingCluster(false);
+
+ return;
+ }
+
+ const nextClusters = clusterList.filter((cluster) => cluster.id !== selectedCluster.id);
+
+ setClusterList(nextClusters);
+ setSelectedClusterId(nextClusters[0]?.id ?? '');
+ setIsDeletingCluster(false);
+ setIsDeleteDialogOpen(false);
+ setClusterPendingDelete(null);
+ setServerPendingDelete(null);
+ }
+
+ async function confirmDelete(): Promise<void> {
+ if (!clusterPendingDelete) {
+ return;
+ }
+
+ if (serverPendingDelete) {
+ await deleteUnbootstrappedServer(clusterPendingDelete, serverPendingDelete);
+
+ return;
+ }
+
+ await deleteCluster(clusterPendingDelete);
+ }
+
+ function resetAdvancedConfiguration(): void {
+ setWireguardInterface(clusterDefaults.wireguardInterface);
+ setWireguardManagementPool(clusterDefaults.wireguardManagementPool);
+ setWireguardListenPort(clusterDefaults.wireguardListenPort);
+ setContainerNetworkPool(clusterDefaults.containerNetworkPool);
+ setContainerNetworkPrefix(clusterDefaults.containerNetworkPrefix);
+ setNamespaces(clusterDefaults.namespaces);
+ setDefaultDenyContainers(clusterDefaults.defaultDenyContainers);
+ setCooldVersion(clusterDefaults.cooldVersion);
+ setCorrosionVersion(clusterDefaults.corrosionVersion);
+ setCorrosionGossipPort(clusterDefaults.corrosionGossipPort);
+ setCorrosionApiPort(clusterDefaults.corrosionApiPort);
+ setBuilderEnabled(clusterDefaults.builderEnabled);
+ setBuilderCapacity(clusterDefaults.builderCapacity);
+ setBuilderCpuQuota(clusterDefaults.builderCpuQuota);
+ setBuilderMemoryMax(clusterDefaults.builderMemoryMax);
+ setBuilderTimeoutSecs(clusterDefaults.builderTimeoutSecs);
+ setShowAdvancedConfiguration(false);
+ }
+
+ function resetServerForm(): void {
+ setServerName('');
+ setServerHost('');
+ setServerSshUser('root');
+ setServerSshPort('22');
+ setSelectedPrivateKeyId('');
+ setServerNodeAddress('');
+ setServerBuilderEnabled(selectedCluster?.builderEnabled ?? true);
+ setServerBuilderCapacity(String(selectedCluster?.builderCapacity ?? 2));
+ setServerBuilderCpuQuota(selectedCluster?.builderCpuQuota ?? clusterDefaults.builderCpuQuota);
+ setWireguardListenPortOverride('');
+ setWireguardEndpointOverride('');
+ setServerErrors({});
+ setShowAdvancedServerConfiguration(false);
+ }
+
+ function resetEditServerForm(): void {
+ setEditingServer(null);
+ setEditServerBuilderEnabled(true);
+ setEditServerBuilderCapacity('2');
+ setEditServerBuilderCpuQuota(clusterDefaults.builderCpuQuota);
+ setEditServerErrors({});
+ }
+
return (
<>
<Head title="Clusters" />
- <div className="h-dvh overflow-hidden bg-background text-foreground">
+ <div className="min-h-dvh overflow-y-auto bg-background text-foreground lg:h-dvh lg:overflow-hidden">
<AppNavbar
flux={flux}
clusters={clusterList}
@@ -124,12 +613,14 @@ export default function Clusters({
selectedEnvironmentUuid={selectedEnvironmentUuid}
/>
- <main className="flex h-full min-h-0 overflow-hidden px-6 pt-16">
- <section className="grid min-h-0 w-full grid-cols-1 gap-4 py-6 lg:grid-cols-[20rem_minmax(0,1fr)]">
- <aside className="flex min-h-0 flex-col rounded-lg border border-border bg-card">
+ <main className="flex min-h-dvh overflow-visible px-4 pt-16 lg:h-full lg:min-h-0 lg:overflow-hidden lg:px-6">
+ <section className="grid w-full grid-cols-1 gap-4 py-4 lg:min-h-0 lg:py-6 lg:grid-cols-[20rem_minmax(0,1fr)]">
+ <aside className="flex max-h-80 flex-col rounded-lg border border-border bg-card lg:max-h-none lg:min-h-0">
<div className="flex items-start justify-between gap-3 border-b border-border p-4">
<div>
- <p className="text-xs font-medium uppercase tracking-wide text-muted-foreground">Clusters</p>
+ <p className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
+ Clusters
+ </p>
<h1 className="mt-1 text-lg font-semibold text-foreground">Cluster inventory</h1>
</div>
<Button
@@ -164,7 +655,8 @@ export default function Clusters({
>
<span className="block text-sm font-medium">{cluster.name}</span>
<span className="mt-1 block text-xs text-muted-foreground">
- {cluster.serversCount} {cluster.serversCount === 1 ? 'server' : 'servers'}
+ {cluster.serversCount}{' '}
+ {cluster.serversCount === 1 ? 'server' : 'servers'}
</span>
</button>
))}
@@ -173,7 +665,7 @@ export default function Clusters({
</div>
</aside>
- <section className="min-h-0 overflow-y-auto rounded-lg border border-border bg-card">
+ <section className="overflow-visible rounded-lg border border-border bg-card lg:min-h-0 lg:overflow-y-auto">
{selectedCluster ? (
<div className="flex min-h-full flex-col">
<div className="border-b border-border p-5">
@@ -182,76 +674,286 @@ export default function Clusters({
</p>
<div className="mt-2 flex flex-wrap items-start justify-between gap-3">
<div>
- <h2 className="text-2xl font-semibold text-foreground">{selectedCluster.name}</h2>
+ <h2 className="text-2xl font-semibold text-foreground">
+ {selectedCluster.name}
+ </h2>
<p className="mt-1 max-w-2xl text-sm text-muted-foreground">
{selectedCluster.description ?? 'No description provided.'}
</p>
</div>
- <div className="rounded-md border border-border bg-muted/40 px-3 py-2 text-sm text-muted-foreground">
- {selectedCluster.serversCount}{' '}
- {selectedCluster.serversCount === 1 ? 'server' : 'servers'}
+ <div className="flex flex-wrap items-center gap-2">
+ {selectedCluster.serversCount === 0 ? (
+ <Button
+ type="button"
+ variant="delete"
+ size="sm"
+ onClick={openDeleteClusterDialog}
+ disabled={isDeletingCluster}
+ >
+ {isDeletingCluster ? 'Deleting...' : 'Delete cluster'}
+ </Button>
+ ) : null}
+ <div className="rounded-md border border-border bg-muted/40 px-3 py-2 text-sm text-muted-foreground">
+ {selectedCluster.serversCount}{' '}
+ {selectedCluster.serversCount === 1 ? 'server' : 'servers'}
+ </div>
</div>
</div>
+ {deleteClusterError ? (
+ <p className="mt-3 text-sm text-destructive">{deleteClusterError}</p>
+ ) : null}
</div>
<div className="flex-1 p-5">
- <div className="mb-4 flex items-center justify-between gap-3">
+ <div className="mb-5 grid grid-cols-1 gap-3 xl:grid-cols-3">
+ <div className="rounded-lg border border-border bg-background p-4">
+ <p className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
+ WireGuard mesh
+ </p>
+ <dl className="mt-3 space-y-2 text-xs">
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Interface</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.wireguardInterface}
+ </dd>
+ </div>
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Management pool</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.wireguardManagementPool}
+ </dd>
+ </div>
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Listen port</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.wireguardListenPort}
+ </dd>
+ </div>
+ </dl>
+ </div>
+
+ <div className="rounded-lg border border-border bg-background p-4">
+ <p className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
+ Container networking
+ </p>
+ <dl className="mt-3 space-y-2 text-xs">
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Pool</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.containerNetworkPool}
+ </dd>
+ </div>
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Prefix</dt>
+ <dd className="font-medium text-foreground">
+ /{selectedCluster.containerNetworkPrefix}
+ </dd>
+ </div>
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Namespaces</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.namespaces.join(', ')}
+ </dd>
+ </div>
+ </dl>
+ </div>
+
+ <div className="rounded-lg border border-border bg-background p-4">
+ <p className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
+ CLI state
+ </p>
+ <dl className="mt-3 space-y-2 text-xs">
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">coold</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.cooldVersion}
+ </dd>
+ </div>
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Corrosion</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.corrosionVersion}
+ </dd>
+ </div>
+ <div className="flex justify-between gap-3">
+ <dt className="text-muted-foreground">Last run</dt>
+ <dd className="font-medium text-foreground">
+ {selectedCluster.lastCliStatus ?? 'Never'}
+ </dd>
+ </div>
+ </dl>
+ {selectedCluster.lastCliSummary ? (
+ <pre className="mt-3 max-h-28 overflow-auto whitespace-pre-wrap rounded bg-muted/30 p-2 text-xs text-muted-foreground">
+ {selectedCluster.lastCliSummary}
+ </pre>
+ ) : null}
+ </div>
+ </div>
+
+ <div className="mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
<div>
- <h3 className="text-base font-semibold text-foreground">Servers in this cluster</h3>
+ <h3 className="text-base font-semibold text-foreground">
+ Servers in this cluster
+ </h3>
<p className="text-sm text-muted-foreground">
- Connection and builder details for each server assigned to this cluster.
+ Connection and builder details for each server assigned to this
+ cluster.
</p>
</div>
+ <Button
+ type="button"
+ variant="coolify"
+ size="sm"
+ aria-label="Add server to cluster"
+ onClick={() => {
+ setServerBuilderEnabled(selectedCluster.builderEnabled);
+ setServerBuilderCapacity(String(selectedCluster.builderCapacity));
+ setServerBuilderCpuQuota(selectedCluster.builderCpuQuota);
+ setIsAddServerDialogOpen(true);
+ }}
+ >
+ <span className="text-base leading-none">+</span>
+ Add server
+ </Button>
</div>
+ {bootstrapServerError ? (
+ <div className="mb-3 rounded-md border border-destructive/30 bg-destructive/10 p-3">
+ <p className="text-sm font-medium text-destructive">
+ {bootstrapServerError}
+ </p>
+ {selectedCluster.lastCliSummary ? (
+ <pre className="mt-2 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-background p-2 text-xs text-muted-foreground">
+ {selectedCluster.lastCliSummary}
+ </pre>
+ ) : null}
+ </div>
+ ) : null}
+
{selectedCluster.servers.length === 0 ? (
<div className="rounded-lg border border-dashed border-border p-8 text-center">
- <p className="text-sm font-medium text-foreground">No servers assigned</p>
+ <p className="text-sm font-medium text-foreground">
+ No servers assigned
+ </p>
<p className="mt-1 text-sm text-muted-foreground">
Servers will appear here after they are added to this cluster.
</p>
</div>
) : (
<div className="grid grid-cols-1 gap-3 xl:grid-cols-2">
- {selectedCluster.servers.map((server) => (
- <article
- key={server.id}
+ {selectedCluster.servers.map((server) => {
+ const isCheckingServer = checkingServers.has(server.id);
+ const isBootstrappingServer = bootstrappingServers.has(server.id);
+ const isDeletingServer = deletingServers.has(server.id);
+
+ return (
+ <article
+ key={server.id}
className="rounded-lg border border-border bg-background p-4"
>
- <div className="flex items-start justify-between gap-3">
- <div>
- <h4 className="text-sm font-semibold text-foreground">
+ <div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
+ <div className="min-w-0">
+ <h4 className="break-words text-sm font-semibold text-foreground">
{server.name}
</h4>
- <p className="mt-1 text-xs text-muted-foreground">{server.host}</p>
+ <p className="mt-1 break-all text-xs text-muted-foreground">
+ {server.host}
+ </p>
+ </div>
+ <div className="flex w-full flex-col items-stretch gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end">
+ <span className="rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-muted-foreground">
+ Bootstrap: {server.status}
+ </span>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={isCheckingServer}
+ onClick={() => void checkServer(server)}
+ >
+ {isCheckingServer
+ ? 'Checking...'
+ : 'Check SSH'}
+ </Button>
+ {server.lastBootstrappedAt === null ? (
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={isBootstrappingServer}
+ onClick={() => void bootstrapServer(server)}
+ >
+ {isBootstrappingServer
+ ? 'Bootstrapping...'
+ : 'Bootstrap'}
+ </Button>
+ ) : null}
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => openEditServerDialog(server)}
+ >
+ Edit server
+ </Button>
+ {server.lastBootstrappedAt === null ? (
+ <Button
+ type="button"
+ variant="delete"
+ size="sm"
+ disabled={isDeletingServer}
+ onClick={() => openDeleteServerDialog(server)}
+ >
+ {isDeletingServer
+ ? 'Deleting...'
+ : 'Delete'}
+ </Button>
+ ) : null}
</div>
- <span className="rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-muted-foreground">
- {server.status}
- </span>
</div>
- <dl className="mt-4 grid grid-cols-2 gap-3 text-xs">
+ <dl className="mt-4 grid grid-cols-1 gap-3 text-xs sm:grid-cols-2">
+ <div>
+ <dt className="text-muted-foreground">
+ Builder capacity
+ </dt>
+ <dd className="mt-1 break-words font-medium text-foreground">
+ {server.builderEnabled
+ ? server.builderCapacity
+ : 'Disabled'}
+ </dd>
+ </div>
<div>
- <dt className="text-muted-foreground">SSH</dt>
- <dd className="mt-1 font-medium text-foreground">
- {server.sshUser}@{server.host}:{server.sshPort}
+ <dt className="text-muted-foreground">
+ Builder CPU quota
+ </dt>
+ <dd className="mt-1 break-words font-medium text-foreground">
+ {server.builderCpuQuota}
</dd>
</div>
<div>
- <dt className="text-muted-foreground">Builder capacity</dt>
- <dd className="mt-1 font-medium text-foreground">
- {server.builderEnabled ? server.builderCapacity : 'Disabled'}
+ <dt className="text-muted-foreground">WireGuard IP</dt>
+ <dd className="mt-1 break-words font-medium text-foreground">
+ {server.wireguardManagementIp ?? 'Not assigned'}
+ </dd>
+ </div>
+ <div>
+ <dt className="text-muted-foreground">CLI node</dt>
+ <dd className="mt-1 break-words font-medium text-foreground">
+ {server.nodeAddress ?? server.host}
</dd>
</div>
<div>
<dt className="text-muted-foreground">Private key</dt>
- <dd className="mt-1 font-medium text-foreground">
+ <dd className="mt-1 break-words font-medium text-foreground">
{server.privateKeyName ?? 'No key'}
</dd>
</div>
<div>
- <dt className="text-muted-foreground">Last bootstrap</dt>
- <dd className="mt-1 font-medium text-foreground">
+ <dt className="text-muted-foreground">
+ Last bootstrap
+ </dt>
+ <dd className="mt-1 break-words font-medium text-foreground">
{formatDate(server.lastBootstrappedAt)}
</dd>
</div>
@@ -260,8 +962,35 @@ export default function Clusters({
<p className="mt-4 text-xs text-muted-foreground">
Capabilities: {normalizeCapabilities(server.capabilities)}
</p>
- </article>
- ))}
+
+ <div className="mt-4 rounded-md border border-border bg-muted/30 p-3 text-xs">
+ <div className="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between">
+ <span className="font-medium text-foreground">
+ Latest SSH check
+ {server.lastStatusCheck
+ ? `: ${server.lastStatusCheck}`
+ : ''}
+ </span>
+ <span className="text-muted-foreground">
+ {server.lastStatusCheckedAt
+ ? formatDate(server.lastStatusCheckedAt)
+ : 'Never run'}
+ </span>
+ </div>
+ {server.lastStatusOutput ? (
+ <pre className="mt-2 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-background p-2 text-muted-foreground">
+ {server.lastStatusOutput}
+ </pre>
+ ) : (
+ <p className="mt-2 text-muted-foreground">
+ Run Check SSH to verify connectivity and capture
+ diagnostic output.
+ </p>
+ )}
+ </div>
+ </article>
+ );
+ })}
</div>
)}
</div>
@@ -278,6 +1007,46 @@ export default function Clusters({
)}
</section>
+ <Dialog
+ open={isDeleteDialogOpen}
+ onOpenChange={(open) => {
+ setIsDeleteDialogOpen(open);
+
+ if (!open) {
+ setClusterPendingDelete(null);
+ setServerPendingDelete(null);
+ }
+ }}
+ >
+ <DialogContent className="max-w-md" showCloseButton={false}>
+ <DialogHeader>
+ <DialogTitle>Confirm deletion</DialogTitle>
+ <DialogDescription>
+ {serverPendingDelete
+ ? `Delete unbootstrapped server ${serverPendingDelete.name}? This only removes it from this cluster.`
+ : `Delete cluster ${clusterPendingDelete?.name ?? ''}? This cannot be undone.`}
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => setIsDeleteDialogOpen(false)}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ variant="delete"
+ disabled={isDeletingCluster || deletingServers.hasAny}
+ onClick={() => void confirmDelete()}
+ >
+ {isDeletingCluster || deletingServers.hasAny ? 'Deleting...' : 'Delete'}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
<Dialog
open={isCreateDialogOpen}
onOpenChange={(open) => {
@@ -288,7 +1057,7 @@ export default function Clusters({
}
}}
>
- <DialogContent>
+ <DialogContent className="max-w-3xl">
<DialogHeader>
<DialogTitle>Create cluster</DialogTitle>
<DialogDescription>
@@ -297,32 +1066,223 @@ export default function Clusters({
</DialogHeader>
<form className="mt-5 flex flex-col gap-4" onSubmit={createCluster}>
- <label className="flex flex-col gap-1 text-sm">
- <span className="font-medium text-foreground">Name</span>
- <input
+ <Field>
+ <FieldLabel>Name</FieldLabel>
+ <Input
value={name}
onChange={(event) => setName(event.target.value)}
- className="rounded-md border border-border bg-background px-3 py-2 text-sm outline-none transition focus:border-ring focus:ring-1 focus:ring-ring"
placeholder="Production Mesh"
+ aria-invalid={errors.name ? true : undefined}
/>
- {errors.name ? <span className="text-xs text-destructive">{errors.name[0]}</span> : null}
- </label>
+ <FieldError message={errors.name?.[0]} />
+ </Field>
- <label className="flex flex-col gap-1 text-sm">
- <span className="font-medium text-foreground">Description</span>
- <textarea
+ <Field>
+ <FieldLabel>Description</FieldLabel>
+ <Textarea
value={description}
onChange={(event) => setDescription(event.target.value)}
- className="min-h-24 rounded-md border border-border bg-background px-3 py-2 text-sm outline-none transition focus:border-ring focus:ring-1 focus:ring-ring"
placeholder="What this cluster is used for"
+ aria-invalid={errors.description ? true : undefined}
/>
- {errors.description ? (
- <span className="text-xs text-destructive">{errors.description[0]}</span>
+ <FieldError message={errors.description?.[0]} />
+ </Field>
+
+ <div className="rounded-lg border border-border bg-muted/20">
+ <button
+ type="button"
+ className="flex w-full items-center justify-between gap-3 px-4 py-3 text-left text-sm font-medium text-foreground"
+ onClick={() => setShowAdvancedConfiguration((value) => !value)}
+ >
+ <span>Advanced configuration</span>
+ <span className="text-xs text-muted-foreground">
+ {showAdvancedConfiguration ? 'Hide' : 'Show'}
+ </span>
+ </button>
+
+ {showAdvancedConfiguration ? (
+ <div className="grid grid-cols-1 gap-4 border-t border-border p-4 sm:grid-cols-2">
+ <Field>
+ <FieldLabel>WireGuard interface</FieldLabel>
+ <Input
+ value={wireguardInterface}
+ onChange={(event) => setWireguardInterface(event.target.value)}
+ aria-invalid={errors.wireguard_interface ? true : undefined}
+ />
+ <FieldError message={errors.wireguard_interface?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>WireGuard pool</FieldLabel>
+ <Input
+ value={wireguardManagementPool}
+ onChange={(event) =>
+ setWireguardManagementPool(event.target.value)
+ }
+ aria-invalid={
+ errors.wireguard_management_pool ? true : undefined
+ }
+ />
+ <FieldError message={errors.wireguard_management_pool?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>WireGuard listen port</FieldLabel>
+ <Input
+ value={wireguardListenPort}
+ onChange={(event) => setWireguardListenPort(event.target.value)}
+ inputMode="numeric"
+ aria-invalid={errors.wireguard_listen_port ? true : undefined}
+ />
+ <FieldError message={errors.wireguard_listen_port?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Container pool</FieldLabel>
+ <Input
+ value={containerNetworkPool}
+ onChange={(event) =>
+ setContainerNetworkPool(event.target.value)
+ }
+ aria-invalid={errors.container_network_pool ? true : undefined}
+ />
+ <FieldError message={errors.container_network_pool?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Container prefix</FieldLabel>
+ <Input
+ value={containerNetworkPrefix}
+ onChange={(event) =>
+ setContainerNetworkPrefix(event.target.value)
+ }
+ inputMode="numeric"
+ aria-invalid={
+ errors.container_network_prefix ? true : undefined
+ }
+ />
+ <FieldError message={errors.container_network_prefix?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Namespaces</FieldLabel>
+ <Input
+ value={namespaces}
+ onChange={(event) => setNamespaces(event.target.value)}
+ placeholder="default,preview"
+ aria-invalid={errors.namespaces ? true : undefined}
+ />
+ <FieldError message={errors.namespaces?.[0]} />
+ </Field>
+
+ <Field className="flex-row items-center gap-2">
+ <input
+ type="checkbox"
+ checked={defaultDenyContainers}
+ onChange={(event) =>
+ setDefaultDenyContainers(event.target.checked)
+ }
+ />
+ <FieldLabel>Default-deny containers</FieldLabel>
+ </Field>
+
+ <Field className="flex-row items-center gap-2">
+ <input
+ type="checkbox"
+ checked={builderEnabled}
+ onChange={(event) => setBuilderEnabled(event.target.checked)}
+ />
+ <FieldLabel>Enable builders</FieldLabel>
+ </Field>
+
+ <Field>
+ <FieldLabel>coold version</FieldLabel>
+ <Input
+ value={cooldVersion}
+ onChange={(event) => setCooldVersion(event.target.value)}
+ aria-invalid={errors.coold_version ? true : undefined}
+ />
+ <FieldError message={errors.coold_version?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Corrosion version</FieldLabel>
+ <Input
+ value={corrosionVersion}
+ onChange={(event) => setCorrosionVersion(event.target.value)}
+ aria-invalid={errors.corrosion_version ? true : undefined}
+ />
+ <FieldError message={errors.corrosion_version?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Corrosion gossip port</FieldLabel>
+ <Input
+ value={corrosionGossipPort}
+ onChange={(event) => setCorrosionGossipPort(event.target.value)}
+ inputMode="numeric"
+ aria-invalid={errors.corrosion_gossip_port ? true : undefined}
+ />
+ <FieldError message={errors.corrosion_gossip_port?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Corrosion API port</FieldLabel>
+ <Input
+ value={corrosionApiPort}
+ onChange={(event) => setCorrosionApiPort(event.target.value)}
+ inputMode="numeric"
+ aria-invalid={errors.corrosion_api_port ? true : undefined}
+ />
+ <FieldError message={errors.corrosion_api_port?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Builder capacity</FieldLabel>
+ <Input
+ value={builderCapacity}
+ onChange={(event) => setBuilderCapacity(event.target.value)}
+ inputMode="numeric"
+ aria-invalid={errors.builder_capacity ? true : undefined}
+ />
+ <FieldError message={errors.builder_capacity?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Builder CPU quota</FieldLabel>
+ <Input
+ value={builderCpuQuota}
+ onChange={(event) => setBuilderCpuQuota(event.target.value)}
+ aria-invalid={errors.builder_cpu_quota ? true : undefined}
+ />
+ <FieldError message={errors.builder_cpu_quota?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Builder memory max</FieldLabel>
+ <Input
+ value={builderMemoryMax}
+ onChange={(event) => setBuilderMemoryMax(event.target.value)}
+ aria-invalid={errors.builder_memory_max ? true : undefined}
+ />
+ <FieldError message={errors.builder_memory_max?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Builder timeout</FieldLabel>
+ <Input
+ value={builderTimeoutSecs}
+ onChange={(event) => setBuilderTimeoutSecs(event.target.value)}
+ inputMode="numeric"
+ aria-invalid={errors.builder_timeout_secs ? true : undefined}
+ />
+ <FieldError message={errors.builder_timeout_secs?.[0]} />
+ </Field>
+ </div>
) : null}
- </label>
+ </div>
<DialogFooter>
- <DialogClose render={<Button type="button" variant="outline" />}>Cancel</DialogClose>
<Button type="submit" variant="coolify" disabled={isSubmitting}>
{isSubmitting ? 'Creating...' : 'Create cluster'}
</Button>
@@ -330,6 +1290,278 @@ export default function Clusters({
</form>
</DialogContent>
</Dialog>
+
+ <Dialog
+ open={isAddServerDialogOpen}
+ onOpenChange={(open) => {
+ setIsAddServerDialogOpen(open);
+
+ if (!open) {
+ resetServerForm();
+ }
+ }}
+ >
+ <DialogContent className="max-w-2xl">
+ <DialogHeader>
+ <DialogTitle>Add server</DialogTitle>
+ <DialogDescription>
+ Add a remote server to this WireGuard cluster. CLI-generated mesh values are
+ saved after bootstrap or extend runs.
+ </DialogDescription>
+ </DialogHeader>
+
+ <form className="mt-5 flex flex-col gap-4" onSubmit={createServer}>
+ <Field>
+ <FieldLabel>Name</FieldLabel>
+ <Input
+ value={serverName}
+ onChange={(event) => setServerName(event.target.value)}
+ placeholder="prod-01"
+ aria-invalid={serverErrors.name ? true : undefined}
+ />
+ <FieldError message={serverErrors.name?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Host</FieldLabel>
+ <Input
+ value={serverHost}
+ onChange={(event) => setServerHost(event.target.value)}
+ placeholder="203.0.113.10"
+ aria-invalid={serverErrors.host ? true : undefined}
+ />
+ <FieldError message={serverErrors.host?.[0]} />
+ </Field>
+
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <Field>
+ <FieldLabel>Bootstrap SSH user</FieldLabel>
+ <Input
+ value={serverSshUser}
+ onChange={(event) => setServerSshUser(event.target.value)}
+ aria-invalid={serverErrors.ssh_user ? true : undefined}
+ />
+ <FieldError message={serverErrors.ssh_user?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Bootstrap SSH port</FieldLabel>
+ <Input
+ value={serverSshPort}
+ onChange={(event) => setServerSshPort(event.target.value)}
+ inputMode="numeric"
+ aria-invalid={serverErrors.ssh_port ? true : undefined}
+ />
+ <FieldError message={serverErrors.ssh_port?.[0]} />
+ </Field>
+ </div>
+
+ <Field>
+ <FieldLabel>Private key</FieldLabel>
+ <select
+ value={selectedPrivateKeyId}
+ onChange={(event) => setSelectedPrivateKeyId(event.target.value)}
+ className="appearance-none rounded-md border border-border bg-background bg-[length:1rem_1rem] bg-[position:right_0.75rem_center] bg-no-repeat px-3 py-2 pr-10 text-sm outline-none transition focus:border-ring focus:ring-1 focus:ring-ring aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40"
+ aria-invalid={serverErrors.private_key_id ? true : undefined}
+ style={{
+ backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 256 256' fill='none' stroke='%23ffffff' stroke-width='28' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m64 96 64 64 64-64'/%3E%3C/svg%3E")`,
+ }}
+ >
+ <option value="">Select a private key</option>
+ {privateKeys.map((privateKey) => (
+ <option key={privateKey.id} value={privateKey.id}>
+ {privateKey.name}
+ </option>
+ ))}
+ </select>
+ <FieldError message={serverErrors.private_key_id?.[0]} />
+ </Field>
+
+ <div className="rounded-lg border border-border bg-muted/20">
+ <button
+ type="button"
+ className="flex w-full items-center justify-between gap-3 px-4 py-3 text-left text-sm font-medium text-foreground"
+ onClick={() => setShowAdvancedServerConfiguration((value) => !value)}
+ >
+ <span>Advanced server configuration</span>
+ <span className="text-xs text-muted-foreground">
+ {showAdvancedServerConfiguration ? 'Hide' : 'Show'}
+ </span>
+ </button>
+
+ {showAdvancedServerConfiguration ? (
+ <div className="grid grid-cols-1 gap-4 border-t border-border p-4 sm:grid-cols-2">
+ <Field>
+ <FieldLabel>CLI node address</FieldLabel>
+ <Input
+ value={serverNodeAddress}
+ onChange={(event) => setServerNodeAddress(event.target.value)}
+ placeholder="Defaults to host"
+ aria-invalid={serverErrors.node_address ? true : undefined}
+ />
+ <FieldError message={serverErrors.node_address?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Builder capacity</FieldLabel>
+ <Input
+ value={serverBuilderCapacity}
+ onChange={(event) =>
+ setServerBuilderCapacity(event.target.value)
+ }
+ inputMode="numeric"
+ aria-invalid={serverErrors.builder_capacity ? true : undefined}
+ />
+ <FieldError message={serverErrors.builder_capacity?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Builder CPU quota</FieldLabel>
+ <Input
+ value={serverBuilderCpuQuota}
+ onChange={(event) =>
+ setServerBuilderCpuQuota(event.target.value)
+ }
+ placeholder="200%"
+ aria-invalid={serverErrors.builder_cpu_quota ? true : undefined}
+ />
+ <FieldError message={serverErrors.builder_cpu_quota?.[0]} />
+ </Field>
+
+ <Field className="flex-row items-center gap-2">
+ <input
+ type="checkbox"
+ checked={serverBuilderEnabled}
+ onChange={(event) =>
+ setServerBuilderEnabled(event.target.checked)
+ }
+ />
+ <FieldLabel>Enable builder on this server</FieldLabel>
+ </Field>
+
+ <Field>
+ <FieldLabel>WireGuard listen override</FieldLabel>
+ <Input
+ value={wireguardListenPortOverride}
+ onChange={(event) =>
+ setWireguardListenPortOverride(event.target.value)
+ }
+ inputMode="numeric"
+ placeholder="Optional"
+ aria-invalid={
+ serverErrors.wireguard_listen_port_override
+ ? true
+ : undefined
+ }
+ />
+ <FieldError
+ message={serverErrors.wireguard_listen_port_override?.[0]}
+ />
+ </Field>
+
+ <Field className="sm:col-span-2">
+ <FieldLabel>WireGuard endpoint override</FieldLabel>
+ <Input
+ value={wireguardEndpointOverride}
+ onChange={(event) =>
+ setWireguardEndpointOverride(event.target.value)
+ }
+ placeholder="host.example.com:51821"
+ aria-invalid={
+ serverErrors.wireguard_endpoint_override ? true : undefined
+ }
+ />
+ <FieldError
+ message={serverErrors.wireguard_endpoint_override?.[0]}
+ />
+ </Field>
+ </div>
+ ) : null}
+ </div>
+
+ <DialogFooter>
+ <Button
+ type="submit"
+ variant="coolify"
+ disabled={isServerSubmitting || !selectedCluster}
+ >
+ {isServerSubmitting ? 'Adding...' : 'Add server'}
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+
+ <Dialog
+ open={isEditServerDialogOpen}
+ onOpenChange={(open) => {
+ setIsEditServerDialogOpen(open);
+
+ if (!open) {
+ resetEditServerForm();
+ }
+ }}
+ >
+ <DialogContent className="max-w-xl">
+ <DialogHeader>
+ <DialogTitle>Edit server</DialogTitle>
+ <DialogDescription>
+ Update builder scheduling limits for {editingServer?.name ?? 'this server'}.
+ Networking and bootstrap settings stay locked after creation.
+ </DialogDescription>
+ </DialogHeader>
+
+ <form className="mt-5 flex flex-col gap-4" onSubmit={updateServer}>
+ <Field className="flex-row items-center gap-2">
+ <input
+ type="checkbox"
+ checked={editServerBuilderEnabled}
+ onChange={(event) => setEditServerBuilderEnabled(event.target.checked)}
+ />
+ <FieldLabel>Enable builder on this server</FieldLabel>
+ </Field>
+
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <Field>
+ <FieldLabel>Builder capacity</FieldLabel>
+ <Input
+ value={editServerBuilderCapacity}
+ onChange={(event) => setEditServerBuilderCapacity(event.target.value)}
+ inputMode="numeric"
+ aria-invalid={editServerErrors.builder_capacity ? true : undefined}
+ />
+ <FieldError message={editServerErrors.builder_capacity?.[0]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>Builder CPU quota</FieldLabel>
+ <Input
+ value={editServerBuilderCpuQuota}
+ onChange={(event) => setEditServerBuilderCpuQuota(event.target.value)}
+ placeholder="200%"
+ aria-invalid={editServerErrors.builder_cpu_quota ? true : undefined}
+ />
+ <FieldError message={editServerErrors.builder_cpu_quota?.[0]} />
+ </Field>
+ </div>
+
+ <p className="text-xs text-muted-foreground">
+ Host, bootstrap credentials, node address, and WireGuard overrides are not
+ editable here.
+ </p>
+
+ <DialogFooter>
+ <Button
+ type="submit"
+ variant="coolify"
+ disabled={isServerUpdateSubmitting || !selectedCluster || !editingServer}
+ >
+ {isServerUpdateSubmitting ? 'Saving...' : 'Save server'}
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
</section>
</main>
</div>
diff --git a/resources/js/v5/components/ui/button.tsx b/resources/js/v5/components/ui/button.tsx
index 01c22f0ebb..3c7faecd9f 100644
--- a/resources/js/v5/components/ui/button.tsx
+++ b/resources/js/v5/components/ui/button.tsx
@@ -19,6 +19,7 @@ const buttonVariants = cva(
ghost: 'hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50',
destructive:
'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40',
+ delete: 'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
diff --git a/resources/js/v5/components/ui/dialog.tsx b/resources/js/v5/components/ui/dialog.tsx
index 2568dd98e6..4a72fbe500 100644
--- a/resources/js/v5/components/ui/dialog.tsx
+++ b/resources/js/v5/components/ui/dialog.tsx
@@ -1,6 +1,8 @@
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
+import { XIcon } from '@phosphor-icons/react';
import type * as React from 'react';
+import { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils';
function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
@@ -21,18 +23,37 @@ function DialogOverlay({ className, ...props }: React.ComponentProps<typeof Dial
);
}
-function DialogContent({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Popup>) {
+function DialogContent({
+ className,
+ children,
+ showCloseButton = true,
+ ...props
+}: React.ComponentProps<typeof DialogPrimitive.Popup> & {
+ showCloseButton?: boolean;
+}) {
return (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Popup
data-slot="dialog-content"
className={cn(
- 'fixed left-1/2 top-1/2 w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-card p-6 shadow-lg outline-none',
+ 'fixed left-1/2 top-1/2 z-50 max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border border-border bg-card p-6 shadow-lg outline-none',
className,
)}
{...props}
- />
+ >
+ {children}
+ {showCloseButton && (
+ <DialogPrimitive.Close
+ data-slot="dialog-close"
+ aria-label="Close dialog"
+ render={<Button type="button" variant="ghost" size="icon-sm" className="absolute top-3 right-3" />}
+ >
+ <XIcon />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ )}
+ </DialogPrimitive.Popup>
</DialogPortal>
);
}
diff --git a/resources/js/v5/components/ui/field.tsx b/resources/js/v5/components/ui/field.tsx
new file mode 100644
index 0000000000..588eff93d1
--- /dev/null
+++ b/resources/js/v5/components/ui/field.tsx
@@ -0,0 +1,35 @@
+import type * as React from 'react';
+
+import { cn } from '@/lib/utils';
+
+type FieldProps = React.ComponentProps<'label'>;
+
+function Field({ className, ...props }: FieldProps) {
+ return <label data-slot="field" className={cn('flex flex-col gap-1 text-sm', className)} {...props} />;
+}
+
+type FieldLabelProps = React.ComponentProps<'span'>;
+
+function FieldLabel({ className, ...props }: FieldLabelProps) {
+ return <span data-slot="field-label" className={cn('font-medium text-foreground', className)} {...props} />;
+}
+
+type FieldErrorProps = React.ComponentProps<'span'> & {
+ message?: string;
+};
+
+function FieldError({ className, message, ...props }: FieldErrorProps) {
+ return (
+ <span
+ aria-hidden={message ? undefined : true}
+ aria-live="polite"
+ data-slot="field-error"
+ className={cn('min-h-4 text-xs leading-4 text-destructive', className)}
+ {...props}
+ >
+ {message ?? ''}
+ </span>
+ );
+}
+
+export { Field, FieldError, FieldLabel };
diff --git a/resources/js/v5/components/ui/input.tsx b/resources/js/v5/components/ui/input.tsx
new file mode 100644
index 0000000000..1bda40f0c6
--- /dev/null
+++ b/resources/js/v5/components/ui/input.tsx
@@ -0,0 +1,18 @@
+import type * as React from 'react';
+
+import { cn } from '@/lib/utils';
+
+function Input({ className, ...props }: React.ComponentProps<'input'>) {
+ return (
+ <input
+ data-slot="input"
+ className={cn(
+ 'rounded-md border border-border bg-background px-3 py-2 text-sm outline-none transition focus:border-ring focus:ring-1 focus:ring-ring aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export { Input };
diff --git a/resources/js/v5/components/ui/textarea.tsx b/resources/js/v5/components/ui/textarea.tsx
new file mode 100644
index 0000000000..4a353f60d1
--- /dev/null
+++ b/resources/js/v5/components/ui/textarea.tsx
@@ -0,0 +1,18 @@
+import type * as React from 'react';
+
+import { cn } from '@/lib/utils';
+
+function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
+ return (
+ <textarea
+ data-slot="textarea"
+ className={cn(
+ 'min-h-24 rounded-md border border-border bg-background px-3 py-2 text-sm outline-none transition focus:border-ring focus:ring-1 focus:ring-ring aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export { Textarea };
diff --git a/resources/js/v5/lib/use-pending-ids.ts b/resources/js/v5/lib/use-pending-ids.ts
new file mode 100644
index 0000000000..b5c994701d
--- /dev/null
+++ b/resources/js/v5/lib/use-pending-ids.ts
@@ -0,0 +1,28 @@
+import { useCallback, useState } from 'react';
+
+export function usePendingIds<T extends string | number>() {
+ const [pendingIds, setPendingIds] = useState<Set<T>>(() => new Set());
+
+ const start = useCallback((id: T): void => {
+ setPendingIds((currentIds) => new Set(currentIds).add(id));
+ }, []);
+
+ const finish = useCallback((id: T): void => {
+ setPendingIds((currentIds) => {
+ const nextIds = new Set(currentIds);
+ nextIds.delete(id);
+
+ return nextIds;
+ });
+ }, []);
+
+ const has = useCallback((id: T): boolean => pendingIds.has(id), [pendingIds]);
+
+ return {
+ pendingIds,
+ has,
+ hasAny: pendingIds.size > 0,
+ start,
+ finish,
+ };
+}
diff --git a/resources/js/v5/types.ts b/resources/js/v5/types.ts
index f03ec31daa..97f924fff5 100644
--- a/resources/js/v5/types.ts
+++ b/resources/js/v5/types.ts
@@ -9,20 +9,48 @@ export type V5Server = {
id: string;
name: string;
host: string;
- sshUser: string;
- sshPort: number;
status: string;
capabilities: string[];
builderEnabled: boolean;
builderCapacity: number;
+ builderCpuQuota: string;
+ nodeAddress: string | null;
+ wireguardListenPortOverride: number | null;
+ wireguardEndpointOverride: string | null;
+ wireguardManagementIp: string | null;
+ wireguardPublicKey: string | null;
+ containerSubnets: Record<string, string> | string[];
privateKeyName: string | null;
lastBootstrappedAt: string | null;
+ lastStatusCheck: string | null;
+ lastStatusOutput: string | null;
+ lastStatusCheckedAt: string | null;
};
export type V5Cluster = {
id: string;
name: string;
description: string | null;
+ wireguardInterface: string;
+ wireguardManagementPool: string;
+ wireguardListenPort: number;
+ containerNetworkPool: string;
+ containerNetworkPrefix: number;
+ namespaces: string[];
+ defaultDenyContainers: boolean;
+ cooldVersion: string;
+ corrosionVersion: string;
+ corrosionGossipPort: number;
+ corrosionApiPort: number;
+ builderEnabled: boolean;
+ builderCapacity: number;
+ builderCpuQuota: string;
+ builderMemoryMax: string;
+ builderTimeoutSecs: number;
+ lastCliAction: string | null;
+ lastCliStatus: string | null;
+ lastCliSummary: string | null;
+ lastCliRanAt: string | null;
serversCount: number;
servers: V5Server[];
};
@@ -38,9 +66,15 @@ export type V5Project = {
environments: V5Environment[];
};
+export type V5PrivateKey = {
+ id: string;
+ name: string;
+};
+
export type V5DashboardProps = {
flux: FluxStatus | null;
clusters?: V5Cluster[];
+ privateKeys?: V5PrivateKey[];
projects?: V5Project[];
selectedProjectUuid?: string | null;
selectedEnvironmentUuid?: string | null;
diff --git a/routes/v5.php b/routes/v5.php
index 655e4f9dcd..7441576756 100644
--- a/routes/v5.php
+++ b/routes/v5.php
@@ -8,4 +8,10 @@ Route::middleware('v5.authenticated')->group(function () {
Route::post('/selection', [DashboardController::class, 'updateSelection'])->name('selection.update');
Route::get('/clusters', [DashboardController::class, 'clustersIndex'])->name('clusters.index');
Route::post('/clusters', [DashboardController::class, 'storeCluster'])->name('clusters.store');
+ Route::delete('/clusters/{cluster}', [DashboardController::class, 'destroyCluster'])->name('clusters.destroy');
+ Route::post('/clusters/{cluster}/servers', [DashboardController::class, 'storeServer'])->name('clusters.servers.store');
+ Route::patch('/clusters/{cluster}/servers/{server}', [DashboardController::class, 'updateServer'])->name('clusters.servers.update');
+ Route::post('/clusters/{cluster}/servers/{server}/check', [DashboardController::class, 'checkServer'])->name('clusters.servers.check');
+ Route::post('/clusters/{cluster}/servers/{server}/bootstrap', [DashboardController::class, 'bootstrapServer'])->name('clusters.servers.bootstrap');
+ Route::delete('/clusters/{cluster}/servers/{server}', [DashboardController::class, 'destroyServer'])->name('clusters.servers.destroy');
});
diff --git a/scripts/coold-vm.sh b/scripts/coold-vm.sh
index 177c289d3c..cbbd35dde5 100755
--- a/scripts/coold-vm.sh
+++ b/scripts/coold-vm.sh
@@ -29,6 +29,7 @@ VERSION="$(read_coolify_env COOLIFY_COOLD_VERSION nightly)"
CORROSION_VERSION="$(read_coolify_env COOLIFY_CORROSION_VERSION v1.0.0)"
FLUX_URL="$(read_coolify_env COOLIFY_COOLD_VM_FLUX_URL http://host.lima.internal:6443)"
BUILDER_CAPACITY="$(read_coolify_env COOLIFY_COOLD_VM_BUILDER_CAPACITY 2)"
+SSH_PORT="$(read_coolify_env COOLIFY_COOLD_VM_SSH_PORT 60002)"
WG_IP="$(read_coolify_env COOLIFY_COOLD_VM_WG_IP "")"
WG_PEER_IP="$(read_coolify_env COOLIFY_COOLD_VM_WG_PEER_IP "")"
WG_PEER_ENDPOINT="$(read_coolify_env COOLIFY_COOLD_VM_WG_PEER_ENDPOINT "")"
@@ -69,6 +70,7 @@ Environment:
COOLIFY_CORROSION_VERSION corrosion release tag to install (default: v1.0.0)
COOLIFY_COOLD_VM_FLUX_URL Flux gRPC URL visible from the VM (default: http://host.lima.internal:6443)
COOLIFY_COOLD_VM_BUILDER_CAPACITY VM builder capacity to advertise (default: 2; set 0 to disable)
+ COOLIFY_COOLD_VM_SSH_PORT Host SSH port forwarded to this VM (default: 60002)
COOLIFY_COOLD_VM_WG_IP Optional WireGuard mgmt IP for this host
COOLIFY_COOLD_VM_CONTAINER_SUBNET Podman mesh subnet for this host
COOLIFY_COOLD_VM_CONTAINER_GATEWAY Podman mesh gateway for this host
@@ -395,6 +397,7 @@ generate_yaml() {
-e "s#{{COOLIFY_REPO}}#$ROOT#g" \
-e "s#{{COOLIFY_COOLD_VERSION}}#$VERSION#g" \
-e "s#{{COOLIFY_CORROSION_VERSION}}#$CORROSION_VERSION#g" \
+ -e "s#{{COOLIFY_COOLD_VM_SSH_PORT}}#$SSH_PORT#g" \
"$TEMPLATE" > "$GENERATED"
}
diff --git a/scripts/dev.sh b/scripts/dev.sh
index 6b8a600d05..05a0ca7443 100755
--- a/scripts/dev.sh
+++ b/scripts/dev.sh
@@ -60,6 +60,11 @@ coold_vm_wg_port() {
read_coolify_env "COOLIFY_COOLD_VM_WG_PORT_${index}" "$((51820 + index))"
}
+coold_vm_ssh_port() {
+ local index="$1"
+ read_coolify_env "COOLIFY_COOLD_VM_SSH_PORT_${index}" "6000${index}"
+}
+
coold_vm_container_subnet() {
local index="$1"
read_coolify_env "COOLIFY_COOLD_VM_CONTAINER_SUBNET_${index}" "10.210.$((index - 1)).0/24"
@@ -172,6 +177,28 @@ lima_ssh_config() {
printf '%s\n' "$config"
}
+lima_ssh_port() {
+ local index="$1"
+ local instance
+ local port
+
+ instance="$(coold_vm_instance "$index")"
+
+ if [ ! -f "$HOME/.lima/${instance}/ssh.config" ]; then
+ echo "ERROR: Lima SSH config for ${instance} was not found. Start it first with scripts/dev.sh up." >&2
+ exit 1
+ fi
+
+ port="$(awk 'tolower($1) == "port" { print $2; exit }' "$HOME/.lima/${instance}/ssh.config")"
+
+ if [ -z "$port" ]; then
+ echo "ERROR: Lima SSH port for ${instance} was not found in $HOME/.lima/${instance}/ssh.config." >&2
+ exit 1
+ fi
+
+ printf '%s\n' "$port"
+}
+
coolify_nodes_arg() {
local count
local nodes=""
@@ -346,6 +373,7 @@ coold_vm() {
shift
COOLIFY_COOLD_LIMA_INSTANCE="$(coold_vm_instance "$index")" \
COOLIFY_COOLD_VM_WG_IP="$(coold_vm_wg_ip "$index")" \
+ COOLIFY_COOLD_VM_SSH_PORT="$(coold_vm_ssh_port "$index")" \
COOLIFY_COOLD_VM_CONTAINER_SUBNET="$(coold_vm_container_subnet "$index")" \
COOLIFY_COOLD_VM_CONTAINER_GATEWAY="$(coold_vm_container_gateway "$index")" \
scripts/coold-vm.sh "$@"
@@ -417,17 +445,31 @@ follow_logs() {
}
sync_v5_dev_lima_servers() {
+ local count
+ local index
+ local instance
+ local server_args=()
+ local ssh_port
local ssh_user
+ count="$(coold_vm_count)"
ssh_user="$(coolify_ssh_user)"
+ for index in $(seq 1 "$count"); do
+ instance="$(coold_vm_instance "$index")"
+ ssh_port="$(lima_ssh_port "$index")"
+ server_args+=(--server="${instance}|host.docker.internal|${ssh_user}|${ssh_port}")
+ done
+
echo "==> Running pending migrations before syncing v5 dev Lima state..."
spin exec -T coolify php artisan migrate --force
echo "==> Seeding dev Lima VM(s) into v5 clusters/servers..."
spin exec -T \
-e COOLIFY_CLI_SSH_USER="$ssh_user" \
- coolify php artisan db:seed --class=V5DevLimaSeeder --force
+ coolify php artisan v5:sync-dev-lima-servers \
+ --builder-capacity="$(read_coolify_env COOLIFY_COOLD_VM_BUILDER_CAPACITY 2)" \
+ "${server_args[@]}"
}
configure_flux_dev_for_vm() {
@@ -491,9 +533,9 @@ up() {
echo "==> Starting Coolify Docker stack with Spin..."
if [ "${#spin_args[@]}" -gt 0 ]; then
- spin up -d "${spin_args[@]}"
+ COOLIFY_CLI_SSH_USER="$(coolify_ssh_user)" spin up -d "${spin_args[@]}"
else
- spin up -d
+ COOLIFY_CLI_SSH_USER="$(coolify_ssh_user)" spin up -d
fi
if [ "$naked" = "true" ]; then
diff --git a/tests/Feature/DevScriptFirewallDelegationTest.php b/tests/Feature/DevScriptFirewallDelegationTest.php
index b776ef38f1..a4759c7b66 100644
--- a/tests/Feature/DevScriptFirewallDelegationTest.php
+++ b/tests/Feature/DevScriptFirewallDelegationTest.php
@@ -61,14 +61,57 @@ it('retries dev coolify bootstrap because fresh Lima setup can complete across p
it('seeds bootstrapped Lima VMs into v5 development server state', function () {
$script = file_get_contents(base_path('scripts/dev.sh'));
+ $compose = file_get_contents(base_path('docker-compose.dev.yml'));
expect($script)->toContain('sync_v5_dev_lima_servers()')
->and($script)->toContain('COOLIFY_CLI_SSH_USER="$ssh_user"')
- ->and($script)->toContain('db:seed --class=V5DevLimaSeeder --force')
- ->and($script)->not->toContain('v5:sync-dev-lima-servers')
+ ->and($script)->toContain('COOLIFY_CLI_SSH_USER="$(coolify_ssh_user)" spin up -d')
+ ->and($script)->toContain('lima_ssh_port "$index"')
+ ->and($script)->toContain('host.docker.internal')
+ ->and($script)->toContain('v5:sync-dev-lima-servers')
+ ->and($script)->toContain('--server="${instance}|host.docker.internal|${ssh_user}|${ssh_port}"')
+ ->and($compose)->toContain('COOLIFY_CLI_SSH_USER: "${COOLIFY_CLI_SSH_USER:-}"')
+ ->and($script)->not->toContain('db:seed --class=V5DevLimaSeeder --force')
->and($script)->not->toContain('--server "${instance}|${node}|$(coolify_ssh_user)|22"');
});
+it('configures predictable Lima SSH local ports for dev VMs', function () {
+ $script = file_get_contents(base_path('scripts/dev.sh'));
+ $vmScript = file_get_contents(base_path('scripts/coold-vm.sh'));
+ $template = file_get_contents(base_path('dev/lima/coold.yaml'));
+
+ expect($script)->toContain('coold_vm_ssh_port()')
+ ->and($script)->toContain('COOLIFY_COOLD_VM_SSH_PORT_')
+ ->and($script)->toContain('6000${index}')
+ ->and($script)->toContain('COOLIFY_COOLD_VM_SSH_PORT="$(coold_vm_ssh_port "$index")"')
+ ->and($vmScript)->toContain('SSH_PORT="$(read_coolify_env COOLIFY_COOLD_VM_SSH_PORT 60002)"')
+ ->and($vmScript)->toContain('{{COOLIFY_COOLD_VM_SSH_PORT}}')
+ ->and($template)->toContain('ssh:')
+ ->and($template)->toContain('localPort: {{COOLIFY_COOLD_VM_SSH_PORT}}');
+});
+
+it('authorizes the seeded testing host key in dev Lima VMs', function () {
+ $template = file_get_contents(base_path('dev/lima/coold.yaml'));
+
+ expect($template)->toContain('coolify_test_public_key=')
+ ->and($template)->toContain('ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuGmoeGq/pojrsyP1pszcNVuZx9iFkCELtxrh31QJ68')
+ ->and($template)->toContain('authorized_keys')
+ ->and($template)->toContain('grep -qxF "$coolify_test_public_key"')
+ ->and($template)->toContain('install -d -m 700 /root/.ssh')
+ ->and($template)->toContain('/root/.ssh/authorized_keys')
+ ->and($template)->toContain('target_home="$(getent passwd 501 | cut -d: -f6 || true)"')
+ ->and($template)->toContain('owner="$(stat -c \'%u:%g\' "$target_home")"')
+ ->and($template)->not->toContain('mode: user')
+ ->and($template)->not->toContain('user="$(basename "$home")"');
+});
+
+it('hardcodes the naked Lima VM ssh port for bootstrap testing', function () {
+ $template = file_get_contents(base_path('.dev/lima/coolify-naked-test.yaml'));
+
+ expect($template)->toContain('ssh:')
+ ->and($template)->toContain('localPort: 60003');
+});
+
it('supports down cleanup as the preferred VM cleanup command', function () {
$script = file_get_contents(base_path('scripts/dev.sh'));
diff --git a/tests/Feature/V5/DashboardTest.php b/tests/Feature/V5/DashboardTest.php
index 343e834650..368039497a 100644
--- a/tests/Feature/V5/DashboardTest.php
+++ b/tests/Feature/V5/DashboardTest.php
@@ -1,5 +1,6 @@
<?php
+use App\Http\Controllers\V5\DashboardController;
use App\Http\Kernel;
use App\Http\Middleware\CheckForcePasswordReset;
use App\Http\Middleware\DecideWhatToDoWithUser;
@@ -16,6 +17,7 @@ use App\Services\Flux\FluxHealth;
use Database\Seeders\V5DevLimaSeeder;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Config;
+use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Mockery\MockInterface;
@@ -38,6 +40,12 @@ it('registers the v5 dashboard route', function () {
->and(Route::has('v5.selection.update'))->toBeTrue()
->and(Route::has('v5.clusters.index'))->toBeTrue()
->and(Route::has('v5.clusters.store'))->toBeTrue()
+ ->and(Route::has('v5.clusters.destroy'))->toBeTrue()
+ ->and(Route::has('v5.clusters.servers.store'))->toBeTrue()
+ ->and(Route::has('v5.clusters.servers.update'))->toBeTrue()
+ ->and(Route::has('v5.clusters.servers.check'))->toBeTrue()
+ ->and(Route::has('v5.clusters.servers.bootstrap'))->toBeTrue()
+ ->and(Route::has('v5.clusters.servers.destroy'))->toBeTrue()
->and(Route::has('v5.coolify.version'))->toBeFalse()
->and(Route::has('v5.coolify.bootstrap'))->toBeFalse();
});
@@ -72,6 +80,15 @@ it('creates v5 cluster tables and lets each server belong to one cluster', funct
$clusterMigration = include database_path('migrations/2026_06_16_130649_v5_create_clusters_table.php');
$clusterMigration->up();
+ $serverMigration = include database_path('migrations/2026_06_16_130650_v5_create_servers_table.php');
+ $serverMigration->up();
+
+ $configurationMigration = include database_path('migrations/2026_06_16_204644_v5_add_wireguard_cli_configuration_to_clusters_and_servers.php');
+ $configurationMigration->up();
+
+ $statusCheckMigration = include database_path('migrations/2026_06_17_172845_add_status_check_fields_to_v5_servers_table.php');
+ $statusCheckMigration->up();
+
expect(Schema::hasTable('v5_clusters'))->toBeTrue()
->and(Schema::hasColumns('v5_clusters', [
'id',
@@ -79,14 +96,30 @@ it('creates v5 cluster tables and lets each server belong to one cluster', funct
'created_by_user_id',
'name',
'description',
+ 'wireguard_interface',
+ 'wireguard_management_pool',
+ 'wireguard_listen_port',
+ 'container_network_pool',
+ 'container_network_prefix',
+ 'namespaces',
+ 'default_deny_containers',
+ 'coold_version',
+ 'corrosion_version',
+ 'corrosion_gossip_port',
+ 'corrosion_api_port',
+ 'builder_enabled',
+ 'builder_capacity',
+ 'builder_cpu_quota',
+ 'builder_memory_max',
+ 'builder_timeout_secs',
+ 'last_cli_action',
+ 'last_cli_status',
+ 'last_cli_summary',
+ 'last_cli_ran_at',
'created_at',
'updated_at',
- ]))->toBeTrue();
-
- $serverMigration = include database_path('migrations/2026_06_16_130650_v5_create_servers_table.php');
- $serverMigration->up();
-
- expect(Schema::hasColumn('v5_servers', 'cluster_id'))->toBeTrue();
+ ]))->toBeTrue()
+ ->and(Schema::hasColumn('v5_servers', 'cluster_id'))->toBeTrue();
});
it('creates v5 server tables in the shared database', function () {
@@ -101,6 +134,12 @@ it('creates v5 server tables in the shared database', function () {
$migration = include database_path('migrations/2026_06_16_130650_v5_create_servers_table.php');
$migration->up();
+ $configurationMigration = include database_path('migrations/2026_06_16_204644_v5_add_wireguard_cli_configuration_to_clusters_and_servers.php');
+ $configurationMigration->up();
+
+ $statusCheckMigration = include database_path('migrations/2026_06_17_172845_add_status_check_fields_to_v5_servers_table.php');
+ $statusCheckMigration->up();
+
expect(Schema::hasTable('v5_servers'))->toBeTrue()
->and(Schema::hasColumns('v5_servers', [
'id',
@@ -116,12 +155,42 @@ it('creates v5 server tables in the shared database', function () {
'capabilities',
'builder_enabled',
'builder_capacity',
+ 'builder_cpu_quota',
+ 'node_address',
+ 'wireguard_listen_port_override',
+ 'wireguard_endpoint_override',
+ 'wireguard_management_ip',
+ 'wireguard_public_key',
+ 'container_subnets',
'last_bootstrapped_at',
+ 'last_status_check',
+ 'last_status_output',
+ 'last_status_checked_at',
'created_at',
'updated_at',
]))->toBeTrue();
});
+it('adds builder cpu quota to existing v5 server tables safely', function () {
+ Schema::dropIfExists('v5_servers');
+
+ Schema::create('v5_servers', function ($table) {
+ $table->id();
+ $table->unsignedInteger('builder_capacity')->default(0);
+ });
+
+ $migration = include database_path('migrations/2026_06_17_165112_v5_add_builder_cpu_quota_to_servers_table.php');
+ $migration->up();
+ $migration->up();
+
+ expect(Schema::hasColumn('v5_servers', 'builder_cpu_quota'))->toBeTrue();
+
+ $migration->down();
+ $migration->down();
+
+ expect(Schema::hasColumn('v5_servers', 'builder_cpu_quota'))->toBeFalse();
+});
+
it('includes v5 tables in the dev testing schema', function () {
$schema = file_get_contents(database_path('schema/testing-schema.sql'));
@@ -132,9 +201,20 @@ it('includes v5 tables in the dev testing schema', function () {
->and($schema)->toContain('CREATE TABLE IF NOT EXISTS "v5_servers"')
->and($schema)->toContain('"cluster_id" INTEGER')
->and($schema)->toContain('CREATE TABLE IF NOT EXISTS "v5_clusters"')
+ ->and($schema)->toContain('"wireguard_interface" TEXT DEFAULT \'wg0\' NOT NULL')
+ ->and($schema)->toContain('"wireguard_management_pool" TEXT DEFAULT \'100.64.0.0/16\' NOT NULL')
+ ->and($schema)->toContain('"container_network_pool" TEXT DEFAULT \'10.210.0.0/16\' NOT NULL')
+ ->and($schema)->toContain('"builder_timeout_secs" INTEGER NOT NULL DEFAULT \'1800\'')
->and($schema)->toContain('"private_key_id" INTEGER')
+ ->and($schema)->toContain('"builder_cpu_quota" TEXT DEFAULT \'200%\' NOT NULL')
+ ->and($schema)->toContain('"wireguard_management_ip" TEXT')
+ ->and($schema)->toContain('"container_subnets" JSON')
+ ->and($schema)->toContain('"last_status_output" TEXT')
->and($schema)->toContain('2026_06_16_130650_v5_create_servers_table')
->and($schema)->toContain('2026_06_16_130649_v5_create_clusters_table')
+ ->and($schema)->toContain('2026_06_16_204644_v5_add_wireguard_cli_configuration_to_clusters_and_servers')
+ ->and($schema)->toContain('2026_06_17_165112_v5_add_builder_cpu_quota_to_servers_table')
+ ->and($schema)->toContain('2026_06_17_172845_add_status_check_fields_to_v5_servers_table')
->and($schema)->not->toContain('2026_06_16_131229_add_cluster_id_to_v5_servers_table')
->and($schema)->not->toContain('2026_06_16_132000_make_v5_server_private_key_nullable')
->and($schema)->not->toContain('v5_hosts');
@@ -169,124 +249,932 @@ it('serves the v5 inertia shell', function () {
$this
->actingAs($user)
->withSession(['currentTeam' => $team])
- ->get('/v5')
+ ->get('/v5')
+ ->assertSuccessful()
+ ->assertSee('<html lang="en" class="dark">', false)
+ ->assertSee('coolify-logo-dev-transparent.png', false)
+ ->assertDontSee('coolify-logo.svg', false)
+ ->assertSee('v5-app', false)
+ ->assertSee('Dashboard', false)
+ ->assertDontSee('Home', false)
+ ->assertDontSee('v5-ready', false)
+ ->assertDontSee('This page is served from Laravel through Inertia and React')
+ ->assertDontSee('Bootstrap server')
+ ->assertDontSee('privateKeys', false)
+ ->assertSee('Running')
+ ->assertSee('Flux is running.')
+ ->assertDontSee('"clusters":', false)
+ ->assertDontSee('cooldServers', false)
+ ->assertDontSee('coold-dev')
+ ->assertDontSee('Create cluster')
+ ->assertDontSee('Cluster details')
+ ->assertDontSee('100.64.0.1')
+ ->assertDontSee('Current team')
+ ->assertDontSee('Your teams')
+ ->assertDontSee('currentTeam', false)
+ ->assertDontSee('teams', false)
+ ->assertDontSee('V5 Shared Team')
+ ->assertDontSee('Shared team details');
+});
+
+it('serves the production v5 favicon outside local environments', function () {
+ app()->detectEnvironment(fn () => 'production');
+
+ $this->withoutVite();
+ fakeFluxHealth();
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->get('/v5')
+ ->assertSuccessful()
+ ->assertSee('coolify-logo.svg', false)
+ ->assertDontSee('coolify-logo-dev-transparent.png', false);
+});
+
+it('shows v5 clusters with their servers on the cluster page', function () {
+ $this->withoutVite();
+ fakeFluxHealth();
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Lima Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Development-Lima',
+ 'description' => 'Local Lima development cluster managed by scripts/dev.sh.',
+ ]);
+ V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'coold-dev',
+ 'host' => 'lima-coold-dev',
+ 'ssh_user' => 'developer',
+ 'ssh_port' => 22,
+ 'status' => 'installed',
+ 'capabilities' => ['coold', 'builder'],
+ 'builder_enabled' => true,
+ 'builder_capacity' => 2,
+ 'last_bootstrapped_at' => now(),
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->get('/v5/clusters')
+ ->assertSuccessful()
+ ->assertSee('Clusters', false)
+ ->assertSee('"clusters":[', false)
+ ->assertSee('"privateKeys":[', false)
+ ->assertSee('"name":"Lima Key"', false)
+ ->assertSee('"name":"Development-Lima"', false)
+ ->assertSee('"serversCount":1', false)
+ ->assertSee('"name":"coold-dev"', false)
+ ->assertSee('"host":"lima-coold-dev"', false)
+ ->assertDontSee('"sshUser"', false)
+ ->assertDontSee('"sshPort"', false)
+ ->assertSee('"builderEnabled":true', false)
+ ->assertSee('"builderCapacity":2', false)
+ ->assertSee('"wireguardInterface":"wg0"', false)
+ ->assertSee('"wireguardManagementPool":"100.64.0.0\\/16"', false)
+ ->assertSee('"containerNetworkPool":"10.210.0.0\\/16"', false)
+ ->assertSee('"namespaces":["default"]', false)
+ ->assertSee('"defaultDenyContainers":true', false)
+ ->assertSee('"cooldVersion":"nightly"', false)
+ ->assertSee('"corrosionVersion":"v1.0.0"', false)
+ ->assertSee('"builderCpuQuota":"200%"', false)
+ ->assertSee('"builderMemoryMax":"2G"', false)
+ ->assertSee('"builderTimeoutSecs":1800', false)
+ ->assertSee('"lastCliStatus":null', false)
+ ->assertSee('"privateKeyName":"Lima Key"', false)
+ ->assertSee('"nodeAddress":null', false)
+ ->assertSee('"wireguardManagementIp":null', false)
+ ->assertSee('"containerSubnets":[]', false)
+ ->assertSee('"lastBootstrappedAt":"', false);
+});
+
+it('creates a v5 cluster for the current team', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson('/v5/clusters', [
+ 'name' => 'Production Mesh',
+ 'description' => 'Primary production cluster.',
+ ])
+ ->assertCreated()
+ ->assertJsonPath('cluster.name', 'Production Mesh')
+ ->assertJsonPath('cluster.description', 'Primary production cluster.')
+ ->assertJsonPath('cluster.wireguardInterface', 'wg0')
+ ->assertJsonPath('cluster.wireguardManagementPool', '100.64.0.0/16')
+ ->assertJsonPath('cluster.wireguardListenPort', 51820)
+ ->assertJsonPath('cluster.containerNetworkPool', '10.210.0.0/16')
+ ->assertJsonPath('cluster.containerNetworkPrefix', 24)
+ ->assertJsonPath('cluster.namespaces', ['default'])
+ ->assertJsonPath('cluster.defaultDenyContainers', true)
+ ->assertJsonPath('cluster.cooldVersion', 'nightly')
+ ->assertJsonPath('cluster.corrosionVersion', 'v1.0.0')
+ ->assertJsonPath('cluster.corrosionGossipPort', 8787)
+ ->assertJsonPath('cluster.corrosionApiPort', 8080)
+ ->assertJsonPath('cluster.builderEnabled', true)
+ ->assertJsonPath('cluster.builderCapacity', 2)
+ ->assertJsonPath('cluster.builderCpuQuota', '200%')
+ ->assertJsonPath('cluster.builderMemoryMax', '2G')
+ ->assertJsonPath('cluster.builderTimeoutSecs', 1800)
+ ->assertJsonPath('cluster.lastCliAction', null)
+ ->assertJsonPath('cluster.lastCliStatus', null)
+ ->assertJsonPath('cluster.lastCliSummary', null)
+ ->assertJsonPath('cluster.lastCliRanAt', null)
+ ->assertJsonPath('cluster.serversCount', 0)
+ ->assertJsonPath('cluster.servers', []);
+
+ expect(Cluster::query()
+ ->where('team_id', $team->id)
+ ->where('created_by_user_id', $user->id)
+ ->where('name', 'Production Mesh')
+ ->where('description', 'Primary production cluster.')
+ ->where('wireguard_interface', 'wg0')
+ ->where('wireguard_management_pool', '100.64.0.0/16')
+ ->where('container_network_pool', '10.210.0.0/16')
+ ->exists())->toBeTrue();
+});
+
+it('creates a v5 cluster with advanced cli configuration', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson('/v5/clusters', [
+ 'name' => 'Custom Mesh',
+ 'description' => null,
+ 'wireguard_interface' => 'wg-prod',
+ 'wireguard_management_pool' => '100.65.0.0/16',
+ 'wireguard_listen_port' => 51830,
+ 'container_network_pool' => '10.211.0.0/16',
+ 'container_network_prefix' => 25,
+ 'namespaces' => ['default', 'preview'],
+ 'default_deny_containers' => false,
+ 'coold_version' => 'v0.2.0',
+ 'corrosion_version' => 'v1.1.0',
+ 'corrosion_gossip_port' => 8788,
+ 'corrosion_api_port' => 8081,
+ 'builder_enabled' => true,
+ 'builder_capacity' => 4,
+ 'builder_cpu_quota' => '400%',
+ 'builder_memory_max' => '4G',
+ 'builder_timeout_secs' => 2400,
+ ])
+ ->assertCreated()
+ ->assertJsonPath('cluster.wireguardInterface', 'wg-prod')
+ ->assertJsonPath('cluster.wireguardManagementPool', '100.65.0.0/16')
+ ->assertJsonPath('cluster.wireguardListenPort', 51830)
+ ->assertJsonPath('cluster.containerNetworkPool', '10.211.0.0/16')
+ ->assertJsonPath('cluster.containerNetworkPrefix', 25)
+ ->assertJsonPath('cluster.namespaces', ['default', 'preview'])
+ ->assertJsonPath('cluster.defaultDenyContainers', false)
+ ->assertJsonPath('cluster.cooldVersion', 'v0.2.0')
+ ->assertJsonPath('cluster.corrosionVersion', 'v1.1.0')
+ ->assertJsonPath('cluster.builderCapacity', 4)
+ ->assertJsonPath('cluster.builderCpuQuota', '400%')
+ ->assertJsonPath('cluster.builderMemoryMax', '4G')
+ ->assertJsonPath('cluster.builderTimeoutSecs', 2400);
+});
+
+it('validates advanced v5 cluster cli configuration', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson('/v5/clusters', [
+ 'name' => 'Broken Mesh',
+ 'wireguard_management_pool' => 'not-a-cidr',
+ 'container_network_pool' => '10.211.0.0',
+ 'wireguard_listen_port' => 70000,
+ 'namespaces' => ['Default'],
+ ])
+ ->assertUnprocessable()
+ ->assertJsonValidationErrors([
+ 'wireguard_management_pool',
+ 'container_network_pool',
+ 'wireguard_listen_port',
+ 'namespaces.0',
+ ]);
+});
+
+it('adds a v5 server to a cluster for the current team', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Production SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ 'builder_enabled' => true,
+ 'builder_capacity' => 3,
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers", [
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'private_key_id' => $privateKey->id,
+ 'node_address' => '203.0.113.10',
+ 'builder_enabled' => true,
+ 'builder_capacity' => 3,
+ 'wireguard_listen_port_override' => 51821,
+ 'wireguard_endpoint_override' => 'prod-01.example.com:51821',
+ ])
+ ->assertCreated()
+ ->assertJsonPath('cluster.serversCount', 1)
+ ->assertJsonPath('cluster.servers.0.name', 'prod-01')
+ ->assertJsonPath('cluster.servers.0.host', '203.0.113.10')
+ ->assertJsonMissingPath('cluster.servers.0.sshUser')
+ ->assertJsonMissingPath('cluster.servers.0.sshPort')
+ ->assertJsonPath('cluster.servers.0.privateKeyName', 'Production SSH Key')
+ ->assertJsonPath('cluster.servers.0.nodeAddress', '203.0.113.10')
+ ->assertJsonPath('cluster.servers.0.builderEnabled', true)
+ ->assertJsonPath('cluster.servers.0.builderCapacity', 3)
+ ->assertJsonPath('cluster.servers.0.builderCpuQuota', '200%')
+ ->assertJsonPath('cluster.servers.0.capabilities', ['coold', 'builder'])
+ ->assertJsonPath('cluster.servers.0.wireguardListenPortOverride', 51821)
+ ->assertJsonPath('cluster.servers.0.wireguardEndpointOverride', 'prod-01.example.com:51821')
+ ->assertJsonPath('cluster.servers.0.wireguardManagementIp', null)
+ ->assertJsonPath('cluster.servers.0.containerSubnets', []);
+
+ expect(V5Server::query()
+ ->where('team_id', $team->id)
+ ->where('cluster_id', $cluster->id)
+ ->where('created_by_user_id', $user->id)
+ ->where('name', 'prod-01')
+ ->where('host', '203.0.113.10')
+ ->where('ssh_user', 'root')
+ ->where('ssh_port', 22)
+ ->where('private_key_id', $privateKey->id)
+ ->where('node_address', '203.0.113.10')
+ ->exists())->toBeTrue();
+
+ expect(V5Server::query()->where('name', 'prod-01')->first()->capabilities)
+ ->toBe(['coold', 'builder']);
+});
+
+it('defaults dev Lima wireguard overrides for host docker internal servers', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Testing Host Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Development-Lima',
+ 'description' => null,
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers", [
+ 'name' => 'coolify-naked-test',
+ 'host' => 'host.docker.internal',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 60003,
+ 'private_key_id' => $privateKey->id,
+ ])
+ ->assertCreated()
+ ->assertJsonPath('cluster.servers.0.wireguardListenPortOverride', 51823)
+ ->assertJsonPath('cluster.servers.0.wireguardEndpointOverride', 'host.lima.internal:51823');
+});
+
+it('rejects adding a v5 server to another teams cluster', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $otherTeam = Team::withoutEvents(fn () => Team::query()->create([
+ 'name' => 'Other V5 Team',
+ 'description' => null,
+ 'personal_team' => false,
+ 'show_boarding' => false,
+ ]));
+ $cluster = Cluster::query()->create([
+ 'team_id' => $otherTeam->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Other Mesh',
+ 'description' => null,
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers", [
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ ])
+ ->assertForbidden();
+});
+
+it('validates v5 server creation input', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers", [
+ 'name' => '',
+ 'host' => '',
+ 'ssh_user' => '',
+ 'ssh_port' => 70000,
+ 'private_key_id' => null,
+ 'wireguard_listen_port_override' => 70000,
+ ])
+ ->assertUnprocessable()
+ ->assertJsonValidationErrors([
+ 'name',
+ 'host',
+ 'ssh_user',
+ 'ssh_port',
+ 'private_key_id',
+ 'wireguard_listen_port_override',
+ ]);
+});
+
+it('rejects private keys from another team when adding a v5 server', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $otherTeam = Team::withoutEvents(fn () => Team::query()->create([
+ 'name' => 'Other V5 Team',
+ 'description' => null,
+ 'personal_team' => false,
+ 'show_boarding' => false,
+ ]));
+ $otherPrivateKey = createV5PrivateKey($otherTeam, 'Other SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers", [
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'private_key_id' => $otherPrivateKey->id,
+ ])
+ ->assertUnprocessable()
+ ->assertJsonValidationErrors(['private_key_id']);
+});
+
+it('checks v5 server ssh status and stores diagnostic output', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Production SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'status' => 'pending',
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
+ ]);
+
+ Process::fake([
+ '*' => Process::result(output: "SSH connection OK\nprod-01\nLinux aarch64\n/usr/bin/docker\n"),
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers/{$server->id}/check")
+ ->assertSuccessful()
+ ->assertJsonPath('cluster.servers.0.status', 'pending')
+ ->assertJsonPath('cluster.servers.0.lastStatusCheck', 'reachable')
+ ->assertJsonPath('cluster.servers.0.lastStatusOutput', "SSH connection OK\nprod-01\nLinux aarch64\n/usr/bin/docker");
+
+ Process::assertRan(fn ($process) => str_contains(json_encode($process->command), '203.0.113.10'));
+ Process::assertRan(fn ($process) => in_array('LogLevel=ERROR', $process->command, true));
+
+ $server->refresh();
+
+ expect($server->status)->toBe('pending')
+ ->and($server->last_status_check)->toBe('reachable')
+ ->and($server->last_status_output)->toContain('SSH connection OK')
+ ->and($server->last_status_checked_at)->not->toBeNull();
+});
+
+it('writes quiet ssh options for v5 bootstrap ssh config', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Production SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ ]);
+ $server->load('privateKey');
+
+ $tempDirectory = storage_path('framework/testing/v5_bootstrap_'.str()->random(8));
+ mkdir($tempDirectory, 0700, true);
+
+ try {
+ $controller = app(DashboardController::class);
+ $reflection = new ReflectionClass($controller);
+ $method = $reflection->getMethod('writeBootstrapSshConfig');
+ $method->setAccessible(true);
+
+ $sshConfigLocation = $method->invoke($controller, collect([$server]), $tempDirectory);
+ $config = file_get_contents($sshConfigLocation);
+
+ expect($config)->toContain(' LogLevel ERROR')
+ ->and($config)->toContain(' UserKnownHostsFile /dev/null')
+ ->and($config)->toContain(' StrictHostKeyChecking no');
+ } finally {
+ collect(scandir($tempDirectory) ?: [])
+ ->reject(fn (string $file) => in_array($file, ['.', '..'], true))
+ ->each(fn (string $file) => @unlink($tempDirectory.'/'.$file));
+ @rmdir($tempDirectory);
+ }
+});
+
+it('bootstraps a single v5 server with the Coolify CLI', function () {
+ createSharedUserAndTeamTables();
+ Config::set('coold.coolify_cli_bin', '/tmp/coolify');
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Production SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ 'namespaces' => ['default', 'preview'],
+ 'container_network_pool' => '10.211.0.0/16',
+ 'container_network_prefix' => 25,
+ 'wireguard_management_pool' => '100.65.0.0/16',
+ 'wireguard_interface' => 'wg-prod',
+ 'wireguard_listen_port' => 51830,
+ 'coold_version' => 'v0.2.0',
+ 'corrosion_version' => 'v1.1.0',
+ 'corrosion_gossip_port' => 8788,
+ 'corrosion_api_port' => 8081,
+ 'builder_enabled' => true,
+ 'builder_capacity' => 4,
+ 'builder_cpu_quota' => '400%',
+ 'builder_memory_max' => '4G',
+ 'builder_timeout_secs' => 2400,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 2222,
+ 'status' => 'pending',
+ 'capabilities' => ['builder'],
+ 'builder_enabled' => true,
+ 'builder_capacity' => 4,
+ 'wireguard_listen_port_override' => 51831,
+ 'wireguard_endpoint_override' => 'prod-01.example.com:51831',
+ ]);
+
+ Process::fake([
+ '*' => Process::result(output: "Bootstrap completed\n"),
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers/{$server->id}/bootstrap")
+ ->assertSuccessful()
+ ->assertJsonPath('cluster.lastCliAction', 'bootstrap')
+ ->assertJsonPath('cluster.lastCliStatus', 'succeeded')
+ ->assertJsonPath('cluster.lastCliSummary', 'Bootstrap completed')
+ ->assertJsonPath('cluster.servers.0.status', 'installed')
+ ->assertJsonPath('cluster.servers.0.capabilities', ['builder', 'coold'])
+ ->assertJsonPath('cluster.servers.0.lastBootstrappedAt', fn (?string $value) => $value !== null);
+
+ Process::assertRan(function ($process) use ($server): bool {
+ $command = $process->command;
+ $node = "v5-server-{$server->id}";
+
+ return $command[0] === '/tmp/coolify'
+ && in_array('init', $command, true)
+ && in_array('bootstrap', $command, true)
+ && in_array($node, $command, true)
+ && in_array('--ssh-config', $command, true)
+ && in_array('default,preview', $command, true)
+ && in_array('10.211.0.0/16', $command, true)
+ && in_array('100.65.0.0/16', $command, true)
+ && in_array('wg-prod', $command, true)
+ && in_array('v0.2.0', $command, true)
+ && in_array('v1.1.0', $command, true)
+ && in_array("{$node}=51831", $command, true)
+ && in_array("{$node}=prod-01.example.com:51831", $command, true)
+ && in_array('--enable-builder', $command, true)
+ && in_array('--yes', $command, true)
+ && ! in_array('--new-nodes', $command, true);
+ });
+
+ $cluster->refresh();
+ $server->refresh();
+
+ expect($cluster->last_cli_status)->toBe('succeeded')
+ ->and($cluster->last_cli_summary)->toBe('Bootstrap completed')
+ ->and($server->status)->toBe('installed')
+ ->and($server->last_bootstrapped_at)->not->toBeNull();
+});
+
+it('does not run a macOS development Coolify CLI binary from Docker during v5 server bootstrap', function () {
+ createSharedUserAndTeamTables();
+ Config::set('coold.coolify_cli_bin', '/usr/local/bin/coolify');
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Production SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'status' => 'pending',
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
+ ]);
+
+ Process::fake([
+ '*' => Process::result(output: "Bootstrap completed\n"),
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers/{$server->id}/bootstrap")
+ ->assertSuccessful();
+
+ Process::assertRan(fn ($process): bool => $process->command[0] === '/usr/local/bin/coolify');
+});
+
+it('keeps a v5 server pending when Coolify CLI bootstrap fails', function () {
+ createSharedUserAndTeamTables();
+ Config::set('coold.coolify_cli_bin', '/tmp/coolify');
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Production SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'status' => 'pending',
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
+ ]);
+
+ Process::fake([
+ '*' => Process::result(errorOutput: "bootstrap failed\n", exitCode: 1),
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers/{$server->id}/bootstrap")
+ ->assertServerError()
+ ->assertJsonPath('message', 'bootstrap failed')
+ ->assertJsonPath('cluster.lastCliAction', 'bootstrap')
+ ->assertJsonPath('cluster.lastCliStatus', 'failed')
+ ->assertJsonPath('cluster.lastCliSummary', 'bootstrap failed')
+ ->assertJsonPath('cluster.servers.0.status', 'pending')
+ ->assertJsonPath('cluster.servers.0.lastBootstrappedAt', null);
+
+ $server->refresh();
+
+ expect($server->status)->toBe('pending')
+ ->and($server->last_bootstrapped_at)->toBeNull();
+});
+
+it('extends a v5 cluster when bootstrapping a new server', function () {
+ createSharedUserAndTeamTables();
+ Config::set('coold.coolify_cli_bin', '/tmp/coolify');
+
+ [$user, $team] = createV5UserWithTeam();
+ $oldPrivateKey = createV5PrivateKey($team, 'Old SSH Key');
+ $newPrivateKey = createV5PrivateKey($team, 'New SSH Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $oldServer = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $oldPrivateKey->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'ubuntu',
+ 'ssh_port' => 2222,
+ 'status' => 'installed',
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
+ 'last_bootstrapped_at' => now()->subDay(),
+ ]);
+ $newServer = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $newPrivateKey->id,
+ 'name' => 'prod-02',
+ 'host' => '203.0.113.11',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'status' => 'pending',
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
+ ]);
+
+ Process::fake([
+ '*' => Process::result(output: "Extend completed\n"),
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->postJson("/v5/clusters/{$cluster->id}/servers/{$newServer->id}/bootstrap")
->assertSuccessful()
- ->assertSee('<html lang="en" class="dark">', false)
- ->assertSee('coolify-logo-dev-transparent.png', false)
- ->assertDontSee('coolify-logo.svg', false)
- ->assertSee('v5-app', false)
- ->assertSee('Dashboard', false)
- ->assertDontSee('Home', false)
- ->assertDontSee('v5-ready', false)
- ->assertDontSee('This page is served from Laravel through Inertia and React')
- ->assertDontSee('Bootstrap server')
- ->assertDontSee('privateKeys', false)
- ->assertSee('Running')
- ->assertSee('Flux is running.')
- ->assertDontSee('"clusters":', false)
- ->assertDontSee('cooldServers', false)
- ->assertDontSee('coold-dev')
- ->assertDontSee('Create cluster')
- ->assertDontSee('Cluster details')
- ->assertDontSee('100.64.0.1')
- ->assertDontSee('Current team')
- ->assertDontSee('Your teams')
- ->assertDontSee('currentTeam', false)
- ->assertDontSee('teams', false)
- ->assertDontSee('V5 Shared Team')
- ->assertDontSee('Shared team details');
-});
+ ->assertJsonPath('cluster.lastCliAction', 'extend')
+ ->assertJsonPath('cluster.lastCliStatus', 'succeeded')
+ ->assertJsonPath('cluster.lastCliSummary', 'Extend completed')
+ ->assertJsonPath('cluster.servers.0.status', 'installed')
+ ->assertJsonPath('cluster.servers.1.status', 'installed');
+
+ Process::assertRan(function ($process) use ($oldServer, $newServer): bool {
+ $command = $process->command;
+ $oldNode = "v5-server-{$oldServer->id}";
+ $newNode = "v5-server-{$newServer->id}";
+
+ return in_array('extend', $command, true)
+ && in_array("{$oldNode},{$newNode}", $command, true)
+ && in_array('--new-nodes', $command, true)
+ && in_array($newNode, $command, true)
+ && in_array('--ssh-config', $command, true);
+ });
-it('serves the production v5 favicon outside local environments', function () {
- app()->detectEnvironment(fn () => 'production');
+ $oldServer->refresh();
+ $newServer->refresh();
- $this->withoutVite();
- fakeFluxHealth();
+ expect($oldServer->status)->toBe('installed')
+ ->and($newServer->status)->toBe('installed')
+ ->and($newServer->last_bootstrapped_at)->not->toBeNull();
+});
+
+it('deletes an unbootstrapped v5 server from a cluster', function () {
createSharedUserAndTeamTables();
[$user, $team] = createV5UserWithTeam();
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'status' => 'pending',
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
+ ]);
$this
->actingAs($user)
->withSession(['currentTeam' => $team])
- ->get('/v5')
+ ->deleteJson("/v5/clusters/{$cluster->id}/servers/{$server->id}")
->assertSuccessful()
- ->assertSee('coolify-logo.svg', false)
- ->assertDontSee('coolify-logo-dev-transparent.png', false);
+ ->assertJsonPath('cluster.serversCount', 0)
+ ->assertJsonPath('cluster.servers', []);
+
+ expect(V5Server::query()->whereKey($server->id)->exists())->toBeFalse();
});
-it('shows v5 clusters with their servers on the cluster page', function () {
- $this->withoutVite();
- fakeFluxHealth();
+it('does not delete a bootstrapped v5 server', function () {
createSharedUserAndTeamTables();
[$user, $team] = createV5UserWithTeam();
- $privateKey = createV5PrivateKey($team, 'Lima Key');
$cluster = Cluster::query()->create([
'team_id' => $team->id,
'created_by_user_id' => $user->id,
- 'name' => 'Development-Lima',
- 'description' => 'Local Lima development cluster managed by scripts/dev.sh.',
+ 'name' => 'Production Mesh',
+ 'description' => null,
]);
- V5Server::query()->create([
+ $server = V5Server::query()->create([
'team_id' => $team->id,
'cluster_id' => $cluster->id,
'created_by_user_id' => $user->id,
- 'private_key_id' => $privateKey->id,
- 'name' => 'coold-dev',
- 'host' => 'lima-coold-dev',
- 'ssh_user' => 'developer',
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
'ssh_port' => 22,
'status' => 'installed',
- 'capabilities' => ['coold', 'builder'],
- 'builder_enabled' => true,
- 'builder_capacity' => 2,
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
'last_bootstrapped_at' => now(),
]);
$this
->actingAs($user)
->withSession(['currentTeam' => $team])
- ->get('/v5/clusters')
- ->assertSuccessful()
- ->assertSee('Clusters', false)
- ->assertSee('"clusters":[', false)
- ->assertSee('"name":"Development-Lima"', false)
- ->assertSee('"serversCount":1', false)
- ->assertSee('"name":"coold-dev"', false)
- ->assertSee('"host":"lima-coold-dev"', false)
- ->assertSee('"sshUser":"developer"', false)
- ->assertSee('"sshPort":22', false)
- ->assertSee('"builderEnabled":true', false)
- ->assertSee('"builderCapacity":2', false)
- ->assertSee('"privateKeyName":"Lima Key"', false)
- ->assertSee('"lastBootstrappedAt":"', false);
+ ->deleteJson("/v5/clusters/{$cluster->id}/servers/{$server->id}")
+ ->assertConflict()
+ ->assertJsonPath('message', 'Only unbootstrapped servers can be deleted.');
+
+ expect(V5Server::query()->whereKey($server->id)->exists())->toBeTrue();
});
-it('creates a v5 cluster for the current team', function () {
+it('updates editable v5 server builder details without changing networking', function () {
createSharedUserAndTeamTables();
[$user, $team] = createV5UserWithTeam();
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'status' => 'installed',
+ 'capabilities' => ['coold'],
+ 'builder_enabled' => false,
+ 'builder_capacity' => 0,
+ 'builder_cpu_quota' => '100%',
+ 'node_address' => '10.0.0.10',
+ 'wireguard_listen_port_override' => 51821,
+ 'wireguard_endpoint_override' => 'prod-01.example.com:51821',
+ ]);
$this
->actingAs($user)
->withSession(['currentTeam' => $team])
- ->postJson('/v5/clusters', [
- 'name' => 'Production Mesh',
- 'description' => 'Primary production cluster.',
+ ->patchJson("/v5/clusters/{$cluster->id}/servers/{$server->id}", [
+ 'builder_enabled' => true,
+ 'builder_capacity' => 5,
+ 'builder_cpu_quota' => '350%',
+ 'host' => '198.51.100.99',
+ 'ssh_user' => 'admin',
+ 'ssh_port' => 2222,
+ 'node_address' => '10.0.0.99',
+ 'wireguard_endpoint_override' => 'changed.example.com:51821',
])
- ->assertCreated()
- ->assertJsonPath('cluster.name', 'Production Mesh')
- ->assertJsonPath('cluster.description', 'Primary production cluster.')
- ->assertJsonPath('cluster.serversCount', 0)
- ->assertJsonPath('cluster.servers', []);
+ ->assertSuccessful()
+ ->assertJsonPath('cluster.servers.0.builderEnabled', true)
+ ->assertJsonPath('cluster.servers.0.builderCapacity', 5)
+ ->assertJsonPath('cluster.servers.0.builderCpuQuota', '350%')
+ ->assertJsonPath('cluster.servers.0.host', '203.0.113.10')
+ ->assertJsonMissingPath('cluster.servers.0.sshUser')
+ ->assertJsonMissingPath('cluster.servers.0.sshPort')
+ ->assertJsonPath('cluster.servers.0.nodeAddress', '10.0.0.10')
+ ->assertJsonPath('cluster.servers.0.wireguardEndpointOverride', 'prod-01.example.com:51821');
+
+ $server->refresh();
+
+ expect($server->builder_enabled)->toBeTrue()
+ ->and($server->builder_capacity)->toBe(5)
+ ->and($server->builder_cpu_quota)->toBe('350%')
+ ->and($server->capabilities)->toBe(['coold', 'builder'])
+ ->and($server->host)->toBe('203.0.113.10')
+ ->and($server->ssh_user)->toBe('root')
+ ->and($server->ssh_port)->toBe(22)
+ ->and($server->node_address)->toBe('10.0.0.10')
+ ->and($server->wireguard_endpoint_override)->toBe('prod-01.example.com:51821');
+});
- expect(Cluster::query()
- ->where('team_id', $team->id)
- ->where('created_by_user_id', $user->id)
- ->where('name', 'Production Mesh')
- ->where('description', 'Primary production cluster.')
- ->exists())->toBeTrue();
+it('validates editable v5 server builder details', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Production Mesh',
+ 'description' => null,
+ ]);
+ $server = V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'prod-01',
+ 'host' => '203.0.113.10',
+ 'ssh_user' => 'root',
+ 'ssh_port' => 22,
+ 'status' => 'installed',
+ 'capabilities' => ['builder'],
+ 'builder_enabled' => true,
+ 'builder_capacity' => 2,
+ 'builder_cpu_quota' => '200%',
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->patchJson("/v5/clusters/{$cluster->id}/servers/{$server->id}", [
+ 'builder_enabled' => true,
+ 'builder_capacity' => 1001,
+ 'builder_cpu_quota' => str_repeat('a', 33),
+ ])
+ ->assertUnprocessable()
+ ->assertJsonValidationErrors(['builder_capacity', 'builder_cpu_quota']);
});
it('validates v5 cluster creation input', function () {
@@ -327,6 +1215,95 @@ it('rejects duplicate v5 cluster names in the same team', function () {
->assertJsonValidationErrors(['name']);
});
+it('deletes an empty v5 cluster in the current team', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Empty Mesh',
+ 'description' => null,
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->deleteJson('/v5/clusters/'.$cluster->id)
+ ->assertNoContent();
+
+ expect(Cluster::query()->whereKey($cluster->id)->exists())->toBeFalse();
+});
+
+it('does not delete a v5 cluster that has servers', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Lima Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Development-Lima',
+ 'description' => null,
+ ]);
+ V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'coold-dev',
+ 'host' => 'lima-coold-dev',
+ 'ssh_user' => 'developer',
+ 'ssh_port' => 22,
+ 'status' => 'installed',
+ 'capabilities' => ['coold', 'builder'],
+ 'builder_enabled' => true,
+ 'builder_capacity' => 2,
+ 'last_bootstrapped_at' => now(),
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->deleteJson('/v5/clusters/'.$cluster->id)
+ ->assertUnprocessable()
+ ->assertJsonPath('message', 'Only empty clusters can be deleted.');
+
+ expect(Cluster::query()->whereKey($cluster->id)->exists())->toBeTrue();
+});
+
+it('does not delete a v5 cluster outside the current team', function () {
+ createSharedUserAndTeamTables();
+
+ [$user, $team] = createV5UserWithTeam();
+ $otherTeam = Team::withoutEvents(fn () => Team::query()->create([
+ 'name' => 'Other V5 Team',
+ 'description' => null,
+ 'personal_team' => false,
+ 'show_boarding' => false,
+ ]));
+ $otherUser = User::withoutEvents(fn () => User::query()->create([
+ 'name' => 'Other User',
+ 'email' => '[email protected]',
+ 'email_verified_at' => now(),
+ 'password' => 'password',
+ ]));
+ $cluster = Cluster::query()->create([
+ 'team_id' => $otherTeam->id,
+ 'created_by_user_id' => $otherUser->id,
+ 'name' => 'Other Mesh',
+ 'description' => null,
+ ]);
+
+ $this
+ ->actingAs($user)
+ ->withSession(['currentTeam' => $team])
+ ->deleteJson('/v5/clusters/'.$cluster->id)
+ ->assertNotFound();
+
+ expect(Cluster::query()->whereKey($cluster->id)->exists())->toBeTrue();
+});
+
it('allows the same v5 cluster name in another team without leaking it', function () {
$this->withoutVite();
fakeFluxHealth();
@@ -569,10 +1546,34 @@ it('defines the v5 dashboard page as a shadcn styled canvas shell', function ()
expect(file_exists(resource_path('js/v5/components/top-navigation-loading-indicator.tsx')))->toBeFalse();
});
+it('tracks v5 server actions with reusable per-id loading state', function () {
+ $clustersPage = file_get_contents(resource_path('js/v5/Pages/Clusters.tsx'));
+ $pendingIdsHook = file_get_contents(resource_path('js/v5/lib/use-pending-ids.ts'));
+
+ expect($clustersPage)
+ ->toContain("import { usePendingIds } from '@/lib/use-pending-ids';")
+ ->toContain('const checkingServers = usePendingIds<string>()')
+ ->toContain('const isCheckingServer = checkingServers.has(server.id)')
+ ->toContain('checkingServers.start(server.id)')
+ ->toContain('checkingServers.finish(server.id)')
+ ->not->toContain('const [checkingServerId, setCheckingServerId] = useState<string | null>(null)')
+ ->not->toContain('setCheckingServerId(server.id)')
+ ->not->toContain('setCheckingServerId(null)');
+
+ expect($pendingIdsHook)
+ ->toContain('export function usePendingIds')
+ ->toContain('const [pendingIds, setPendingIds] = useState<Set<T>>(() => new Set())')
+ ->toContain('start')
+ ->toContain('finish')
+ ->toContain('has')
+ ->toContain('hasAny');
+});
+
it('defines the v5 cluster management page and create cluster form', function () {
$clustersPagePath = resource_path('js/v5/Pages/Clusters.tsx');
$clustersPage = file_get_contents($clustersPagePath);
$buttonComponent = file_get_contents(resource_path('js/v5/components/ui/button.tsx'));
+ $dialogComponent = file_get_contents(resource_path('js/v5/components/ui/dialog.tsx'));
$types = file_get_contents(resource_path('js/v5/types.ts'));
expect(file_exists($clustersPagePath))->toBeTrue();
@@ -592,7 +1593,54 @@ it('defines the v5 cluster management page and create cluster form', function ()
->toContain('<DialogTitle>Create cluster</DialogTitle>')
->toContain('<DialogDescription>')
->toContain('<DialogFooter>')
- ->toContain('<DialogClose')
+ ->not->toContain('<DialogClose')
+ ->toContain('Cancel')
+ ->toContain('<DialogContent className="max-w-md" showCloseButton={false}>')
+ ->toContain('<DialogTitle>Confirm deletion</DialogTitle>')
+ ->toContain('variant="delete"')
+ ->toContain('aria-label="Add server to cluster"')
+ ->toContain('setIsAddServerDialogOpen(true)')
+ ->toContain('Add server')
+ ->toContain('className="mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between"')
+ ->toContain('<DialogTitle>Add server</DialogTitle>')
+ ->toContain('DialogContent className="max-w-3xl"')
+ ->toContain('DialogContent className="max-w-2xl"')
+ ->not->toContain('DialogContent className="max-h-[90dvh] max-w-3xl overflow-y-auto"')
+ ->not->toContain('DialogContent className="max-h-[90dvh] max-w-2xl overflow-y-auto"')
+ ->toContain('fetch(`/v5/clusters/${selectedCluster.id}/servers/${server.id}/bootstrap`')
+ ->toContain('Bootstrap')
+ ->toContain('lastCliSummary')
+ ->toContain('Unable to bootstrap this server. Check the CLI state output.')
+ ->toContain('border-destructive/30')
+ ->toContain('fetch(`/v5/clusters/${selectedCluster.id}/servers`')
+ ->toContain('fetch(`/v5/clusters/${selectedCluster.id}/servers/${editingServer.id}`')
+ ->toContain('fetch(`/v5/clusters/${selectedCluster.id}/servers/${server.id}/check`')
+ ->toContain('fetch(`/v5/clusters/${cluster.id}/servers/${server.id}`')
+ ->toContain("method: 'PATCH'")
+ ->toContain("method: 'DELETE'")
+ ->toContain('Check SSH')
+ ->toContain('Bootstrap: {server.status}')
+ ->toContain('Latest SSH check')
+ ->toContain('Delete')
+ ->toContain('<DialogTitle>Edit server</DialogTitle>')
+ ->toContain('Edit server')
+ ->toContain('Save server')
+ ->toContain('editServerBuilderCapacity')
+ ->toContain('editServerBuilderCpuQuota')
+ ->toContain('Networking and bootstrap settings stay locked after creation.')
+ ->toContain('Bootstrap SSH user')
+ ->toContain('Bootstrap SSH port')
+ ->not->toContain('{server.sshUser}@{server.host}:{server.sshPort}')
+ ->toContain('showAdvancedServerConfiguration')
+ ->toContain('wireguardListenPortOverride')
+ ->toContain('wireguardEndpointOverride')
+ ->toContain('privateKeys')
+ ->toContain('selectedPrivateKeyId')
+ ->toContain('Private key')
+ ->toContain('Select a private key')
+ ->toContain('appearance-none')
+ ->toContain('backgroundImage: `url("data:image/svg+xml')
+ ->not->toContain('No private key')
->toContain('Create cluster')
->toContain('Cluster details')
->toContain('Servers in this cluster')
@@ -600,20 +1648,43 @@ it('defines the v5 cluster management page and create cluster form', function ()
->toContain('builderCapacity')
->toContain('privateKeyName')
->toContain('lastBootstrappedAt')
+ ->toContain('deleteCluster')
+ ->toContain('fetch(`/v5/clusters/${cluster.id}`')
+ ->toContain("method: 'DELETE'")
+ ->toContain('Delete cluster')
+ ->toContain('selectedCluster.serversCount === 0')
+ ->toContain('Only empty clusters can be deleted.')
+ ->toContain('min-h-dvh overflow-y-auto bg-background text-foreground lg:h-dvh lg:overflow-hidden')
+ ->toContain('flex min-h-dvh overflow-visible px-4 pt-16 lg:h-full lg:min-h-0 lg:overflow-hidden lg:px-6')
+ ->toContain('flex max-h-80 flex-col rounded-lg border border-border bg-card lg:max-h-none lg:min-h-0')
+ ->toContain('overflow-visible rounded-lg border border-border bg-card lg:min-h-0 lg:overflow-y-auto')
+ ->toContain('flex w-full flex-col items-stretch gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end')
+ ->toContain('mt-4 grid grid-cols-1 gap-3 text-xs sm:grid-cols-2')
->toContain('lg:grid-cols-[20rem_minmax(0,1fr)]')
->not->toContain('lg:grid-cols-[20rem_minmax(0,1fr)_22rem]')
->not->toContain('New cluster')
->not->toContain('<aside className="rounded-lg border border-border bg-card p-5">')
->not->toContain('This is where the magic happens.');
- expect(substr_count($clustersPage, 'variant="coolify"'))->toBe(2)
+ expect(substr_count($clustersPage, 'variant="coolify"'))->toBe(5)
->and($buttonComponent)
->toContain('coolify:')
->toContain('bg-coollabs-50')
- ->toContain('hover:bg-coollabs');
+ ->toContain('hover:bg-coollabs')
+ ->toContain('delete:');
- expect(file_get_contents(resource_path('js/v5/components/ui/dialog.tsx')))
+ expect($dialogComponent)
->toContain('@base-ui/react/dialog')
+ ->toContain('z-50')
+ ->toContain('max-h-[calc(100dvh-2rem)]')
+ ->toContain('overflow-y-auto')
+ ->toContain('top-1/2')
+ ->toContain('-translate-y-1/2')
+ ->not->toContain('top-4 bottom-4')
+ ->not->toContain('top-1/2 w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2')
+ ->toContain('showCloseButton = true')
+ ->toContain('aria-label="Close dialog"')
+ ->toContain('<XIcon />')
->toContain('DialogTitle')
->toContain('DialogDescription');
@@ -628,10 +1699,11 @@ it('defines the v5 cluster management page and create cluster form', function ()
expect(substr_count($v5Css, '--ring: var(--warning);'))->toBe(2);
expect($types)
- ->toContain('sshUser: string;')
- ->toContain('sshPort: number;')
+ ->not->toContain('sshUser: string;')
+ ->not->toContain('sshPort: number;')
->toContain('builderEnabled: boolean;')
->toContain('builderCapacity: number;')
+ ->toContain('builderCpuQuota: string;')
->toContain('privateKeyName: string | null;')
->toContain('lastBootstrappedAt: string | null;');
});
@@ -651,6 +1723,49 @@ it('defines a ghost variant for compact v5 select triggers', function () {
->toContain("position === 'popper' ? false : true");
});
+it('provides reusable v5 form field primitives with reserved validation error space', function () {
+ $fieldPath = resource_path('js/v5/components/ui/field.tsx');
+ $inputPath = resource_path('js/v5/components/ui/input.tsx');
+ $textareaPath = resource_path('js/v5/components/ui/textarea.tsx');
+ $clustersPage = file_get_contents(resource_path('js/v5/Pages/Clusters.tsx'));
+
+ expect(file_exists($fieldPath))->toBeTrue()
+ ->and(file_exists($inputPath))->toBeTrue()
+ ->and(file_exists($textareaPath))->toBeTrue();
+
+ $field = file_get_contents($fieldPath);
+ $input = file_get_contents($inputPath);
+ $textarea = file_get_contents($textareaPath);
+
+ expect($field)
+ ->toContain('function Field(')
+ ->toContain('function FieldLabel(')
+ ->toContain('function FieldError(')
+ ->toContain('min-h-4')
+ ->toContain('aria-live="polite"')
+ ->toContain('message ? undefined : true')
+ ->toContain('export { Field, FieldError, FieldLabel }');
+
+ expect($input)
+ ->toContain('function Input(')
+ ->toContain('aria-invalid:border-destructive')
+ ->toContain('export { Input };');
+
+ expect($textarea)
+ ->toContain('function Textarea(')
+ ->toContain('aria-invalid:border-destructive')
+ ->toContain('export { Textarea };');
+
+ expect($clustersPage)
+ ->toContain("import { Field, FieldError, FieldLabel } from '@/components/ui/field';")
+ ->toContain("import { Input } from '@/components/ui/input';")
+ ->toContain("import { Textarea } from '@/components/ui/textarea';")
+ ->toContain('<FieldError message={errors.name?.[0]} />')
+ ->toContain('<FieldError message={serverErrors.private_key_id?.[0]} />')
+ ->not->toContain('{errors.name ? <span className="text-xs text-destructive">{errors.name[0]}</span> : null}')
+ ->not->toContain('{serverErrors.name ? (');
+});
+
it('uses the requested shadcn preset configuration for v5', function () {
$components = json_decode(file_get_contents(base_path('components.json')), true);
$css = file_get_contents(resource_path('css/v5/app.css'));
@@ -798,19 +1913,60 @@ it('syncs dev Lima VMs into v5 clusters and servers', function () {
$exitCode = Artisan::call('v5:sync-dev-lima-servers', [
'--team-id' => $team->id,
'--user-id' => $user->id,
- '--private-key-id' => $privateKey->id,
'--cluster' => 'Development-Lima',
'--builder-capacity' => 2,
'--server' => [
- 'coold-dev|lima-coold-dev|developer|22',
- 'coold-dev-2|lima-coold-dev-2|developer|22',
+ 'coold-dev|host.docker.internal|developer|61332',
+ 'coold-dev-2|host.docker.internal|developer|61379',
],
]);
expect($exitCode)->toBe(0)
->and(Cluster::query()->where('name', 'Development-Lima')->count())->toBe(1)
- ->and(V5Server::query()->where('name', 'coold-dev')->where('host', 'lima-coold-dev')->exists())->toBeTrue()
- ->and(V5Server::query()->where('name', 'coold-dev-2')->where('host', 'lima-coold-dev-2')->exists())->toBeTrue();
+ ->and(V5Server::query()->where('name', 'coold-dev')->where('host', 'host.docker.internal')->where('ssh_port', 61332)->where('private_key_id', $privateKey->id)->exists())->toBeTrue()
+ ->and(V5Server::query()->where('name', 'coold-dev-2')->where('host', 'host.docker.internal')->where('ssh_port', 61379)->where('private_key_id', $privateKey->id)->exists())->toBeTrue();
+});
+
+it('updates legacy dev Lima hostnames to Docker reachable SSH endpoints', function () {
+ createSharedUserAndTeamTables();
+ [$user, $team] = createV5UserWithTeam();
+ $privateKey = createV5PrivateKey($team, 'Dev Lima Key');
+ $cluster = Cluster::query()->create([
+ 'team_id' => $team->id,
+ 'created_by_user_id' => $user->id,
+ 'name' => 'Development-Lima',
+ 'description' => 'Local Lima development cluster managed by scripts/dev.sh.',
+ ]);
+
+ V5Server::query()->create([
+ 'team_id' => $team->id,
+ 'cluster_id' => $cluster->id,
+ 'created_by_user_id' => $user->id,
+ 'private_key_id' => $privateKey->id,
+ 'name' => 'coold-dev',
+ 'host' => 'lima-coold-dev',
+ 'ssh_user' => 'developer',
+ 'ssh_port' => 22,
+ 'status' => 'installed',
+ 'builder_enabled' => true,
+ 'builder_capacity' => 2,
+ 'last_bootstrapped_at' => now(),
+ ]);
+
+ $exitCode = Artisan::call('v5:sync-dev-lima-servers', [
+ '--team-id' => $team->id,
+ '--user-id' => $user->id,
+ '--cluster' => 'Development-Lima',
+ '--builder-capacity' => 2,
+ '--server' => [
+ 'coold-dev|host.docker.internal|developer|61332',
+ ],
+ ]);
+
+ expect($exitCode)->toBe(0)
+ ->and(V5Server::query()->where('name', 'coold-dev')->count())->toBe(1)
+ ->and(V5Server::query()->where('name', 'coold-dev')->where('host', 'host.docker.internal')->where('ssh_port', 61332)->exists())->toBeTrue()
+ ->and(V5Server::query()->where('host', 'lima-coold-dev')->exists())->toBeFalse();
});
it('seeds dev Lima VMs into v5 clusters and servers idempotently', function () {
@@ -828,8 +1984,8 @@ it('seeds dev Lima VMs into v5 clusters and servers idempotently', function () {
->and($cluster->created_by_user_id)->toBe($user->id)
->and($cluster->description)->toBe('Local Lima development cluster managed by scripts/dev.sh.')
->and(V5Server::query()->count())->toBe(2)
- ->and(V5Server::query()->where('name', 'coold-dev')->where('host', 'lima-coold-dev')->where('ssh_user', get_current_user())->where('ssh_port', 22)->exists())->toBeTrue()
- ->and(V5Server::query()->where('name', 'coold-dev-2')->where('host', 'lima-coold-dev-2')->where('ssh_user', get_current_user())->where('ssh_port', 22)->exists())->toBeTrue()
+ ->and(V5Server::query()->where('name', 'coold-dev')->where('host', 'host.docker.internal')->where('ssh_user', get_current_user())->where('ssh_port', 60001)->exists())->toBeTrue()
+ ->and(V5Server::query()->where('name', 'coold-dev-2')->where('host', 'host.docker.internal')->where('ssh_user', get_current_user())->where('ssh_port', 60002)->exists())->toBeTrue()
->and(V5Server::query()->where('status', 'installed')->count())->toBe(2)
->and(V5Server::query()->where('builder_enabled', true)->where('builder_capacity', 2)->count())->toBe(2)
->and(V5Server::query()->where('cluster_id', $cluster->id)->count())->toBe(2);
@@ -906,6 +2062,26 @@ function createSharedUserAndTeamTables(): void
$table->foreignId('created_by_user_id');
$table->string('name');
$table->text('description')->nullable();
+ $table->string('wireguard_interface')->default('wg0');
+ $table->string('wireguard_management_pool')->default('100.64.0.0/16');
+ $table->unsignedInteger('wireguard_listen_port')->default(51820);
+ $table->string('container_network_pool')->default('10.210.0.0/16');
+ $table->unsignedTinyInteger('container_network_prefix')->default(24);
+ $table->json('namespaces')->nullable();
+ $table->boolean('default_deny_containers')->default(true);
+ $table->string('coold_version')->default('nightly');
+ $table->string('corrosion_version')->default('v1.0.0');
+ $table->unsignedInteger('corrosion_gossip_port')->default(8787);
+ $table->unsignedInteger('corrosion_api_port')->default(8080);
+ $table->boolean('builder_enabled')->default(true);
+ $table->unsignedInteger('builder_capacity')->default(2);
+ $table->string('builder_cpu_quota')->default('200%');
+ $table->string('builder_memory_max')->default('2G');
+ $table->unsignedInteger('builder_timeout_secs')->default(1800);
+ $table->string('last_cli_action')->nullable();
+ $table->string('last_cli_status')->nullable();
+ $table->text('last_cli_summary')->nullable();
+ $table->timestamp('last_cli_ran_at')->nullable();
$table->timestamps();
});
@@ -923,7 +2099,17 @@ function createSharedUserAndTeamTables(): void
$table->json('capabilities')->nullable();
$table->boolean('builder_enabled')->default(false);
$table->unsignedInteger('builder_capacity')->default(0);
+ $table->string('builder_cpu_quota')->default('200%');
+ $table->string('node_address')->nullable();
+ $table->unsignedInteger('wireguard_listen_port_override')->nullable();
+ $table->string('wireguard_endpoint_override')->nullable();
+ $table->string('wireguard_management_ip')->nullable();
+ $table->string('wireguard_public_key')->nullable();
+ $table->json('container_subnets')->nullable();
$table->timestamp('last_bootstrapped_at')->nullable();
+ $table->string('last_status_check')->nullable();
+ $table->text('last_status_output')->nullable();
+ $table->timestamp('last_status_checked_at')->nullable();
$table->timestamps();
});
diff --git a/tests/Unit/MobileInputZoomPreventionTest.php b/tests/Unit/MobileInputZoomPreventionTest.php
new file mode 100644
index 0000000000..54dad08850
--- /dev/null
+++ b/tests/Unit/MobileInputZoomPreventionTest.php
@@ -0,0 +1,27 @@
+<?php
+
+it('uses at least sixteen pixel form controls on mobile to prevent input focus zoom', function (string $stylesheet) {
+ $css = file_get_contents(dirname(__DIR__, 2).'/'.$stylesheet);
+
+ expect($css)->toContain('@media (max-width: 767px)')
+ ->and($css)->toContain('input,')
+ ->and($css)->toContain('textarea,')
+ ->and($css)->toContain('select')
+ ->and($css)->toContain('font-size: 16px');
+})->with([
+ 'current interface' => 'resources/css/app.css',
+ 'v5 interface' => 'resources/css/v5/app.css',
+]);
+
+it('keeps user zoom enabled in the viewport meta tags', function () {
+ $layouts = [
+ 'resources/views/layouts/base.blade.php',
+ 'resources/views/v5/app.blade.php',
+ ];
+
+ foreach ($layouts as $layout) {
+ expect(file_get_contents(dirname(__DIR__, 2).'/'.$layout))
+ ->not->toContain('maximum-scale')
+ ->not->toContain('user-scalable=no');
+ }
+});