mirror of
https://github.com/coollabsio/coolify.git
synced 2026-08-24 10:05:47 -05:00
Add WireGuard networking fields (interface, management pool, listen port), container network pool, coold/corrosion versioning, and builder CPU quota to clusters and servers via new migrations and model fillables. Expose full cluster and server CRUD on the Clusters page with private key selection, pending state tracking, and new form primitives (Field, Input, Textarea). Add server status check fields and a lima test VM config for development.
92 lines
3.1 KiB
PHP
92 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\PrivateKey;
|
|
use App\Models\Team;
|
|
use App\Models\User;
|
|
use App\Models\V5\Cluster;
|
|
use App\Models\V5\Server;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class V5DevLimaSeeder extends Seeder
|
|
{
|
|
private const CLUSTER_NAME = 'Development-Lima';
|
|
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$team = Team::query()->find(0) ?? Team::query()->orderBy('id')->first();
|
|
$user = User::query()->find(0) ?? User::query()->orderBy('id')->first();
|
|
|
|
if (! $team instanceof Team || ! $user instanceof User) {
|
|
return;
|
|
}
|
|
|
|
$cluster = Cluster::query()->updateOrCreate([
|
|
'team_id' => $team->id,
|
|
'name' => self::CLUSTER_NAME,
|
|
], [
|
|
'created_by_user_id' => $user->id,
|
|
'description' => 'Local Lima development cluster managed by scripts/dev.sh.',
|
|
]);
|
|
|
|
$privateKey = PrivateKey::query()
|
|
->where('team_id', $team->id)
|
|
->where('is_git_related', false)
|
|
->orderBy('id')
|
|
->first();
|
|
|
|
$builderCapacity = max(0, (int) config('coold.dev_builder_capacity', 2));
|
|
$builderEnabled = $builderCapacity > 0;
|
|
$capabilities = $builderEnabled ? ['coold', 'builder'] : ['coold'];
|
|
$sshUser = (string) config('coold.dev_ssh_user', get_current_user());
|
|
|
|
foreach ($this->servers() as $server) {
|
|
Server::query()->updateOrCreate([
|
|
'team_id' => $team->id,
|
|
'host' => $server['host'],
|
|
'ssh_port' => $server['ssh_port'],
|
|
], [
|
|
'cluster_id' => $cluster->id,
|
|
'created_by_user_id' => $user->id,
|
|
'private_key_id' => $privateKey?->id,
|
|
'name' => $server['name'],
|
|
'ssh_user' => $sshUser,
|
|
'status' => 'installed',
|
|
'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, wireguard_listen_port_override: int, wireguard_endpoint_override: string}>
|
|
*/
|
|
private function servers(): array
|
|
{
|
|
return [
|
|
[
|
|
'name' => 'coold-dev',
|
|
'host' => 'host.docker.internal',
|
|
'ssh_port' => 60001,
|
|
'wireguard_listen_port_override' => 51821,
|
|
'wireguard_endpoint_override' => 'host.lima.internal:51821',
|
|
],
|
|
[
|
|
'name' => 'coold-dev-2',
|
|
'host' => 'host.docker.internal',
|
|
'ssh_port' => 60002,
|
|
'wireguard_listen_port_override' => 51822,
|
|
'wireguard_endpoint_override' => 'host.lima.internal:51822',
|
|
],
|
|
];
|
|
}
|
|
}
|