refactor: Add localhost as Server if it doesn't exist and not in cloud environment

This commit is contained in:
Andras Bacsai
2024-09-26 12:31:39 +02:00
parent b218356f2d
commit 68ab8dc14c

View File

@@ -65,37 +65,39 @@ class ProductionSeeder extends Seeder
]); ]);
} }
// Add Coolify host (localhost) as Server if it doesn't exist // Add Coolify host (localhost) as Server if it doesn't exist
if (Server::find(0) == null && ! isCloud()) { if (! isCloud()) {
$server_details = [ if (Server::find(0) == null) {
'id' => 0, $server_details = [
'name' => 'localhost', 'id' => 0,
'description' => "This is the server where Coolify is running on. Don't delete this!", 'name' => 'localhost',
'user' => 'root', 'description' => "This is the server where Coolify is running on. Don't delete this!",
'ip' => 'host.docker.internal', 'user' => 'root',
'team_id' => 0, 'ip' => 'host.docker.internal',
'private_key_id' => 0, 'team_id' => 0,
]; 'private_key_id' => 0,
$server_details['proxy'] = ServerMetadata::from([ ];
'type' => ProxyTypes::TRAEFIK->value, $server_details['proxy'] = ServerMetadata::from([
'status' => ProxyStatus::EXITED->value, 'type' => ProxyTypes::TRAEFIK->value,
]); 'status' => ProxyStatus::EXITED->value,
$server = Server::create($server_details); ]);
$server->settings->is_reachable = true; $server = Server::create($server_details);
$server->settings->is_usable = true; $server->settings->is_reachable = true;
$server->settings->save(); $server->settings->is_usable = true;
} else { $server->settings->save();
$server = Server::find(0); } else {
$server->settings->is_reachable = true; $server = Server::find(0);
$server->settings->is_usable = true; $server->settings->is_reachable = true;
$server->settings->save(); $server->settings->is_usable = true;
} $server->settings->save();
if (StandaloneDocker::find(0) == null && ! isCloud()) { }
StandaloneDocker::create([ if (StandaloneDocker::find(0) == null) {
'id' => 0, StandaloneDocker::create([
'name' => 'localhost-coolify', 'id' => 0,
'network' => 'coolify', 'name' => 'localhost-coolify',
'server_id' => 0, 'network' => 'coolify',
]); 'server_id' => 0,
]);
}
} }
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) { if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {