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.

fix: create the private key before the server in the prod seeder

Andras Bacsaid3a6576a068e
diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php
index 6b70851280..2ce7a56ccf 100644
--- a/database/seeders/ProductionSeeder.php
+++ b/database/seeders/ProductionSeeder.php
@@ -21,6 +21,8 @@ class ProductionSeeder extends Seeder
{
public function run(): void
{
+
+ $user = 'root';
echo "Starting ProductionSeeder...\n";
if (isCloud()) {
@@ -79,6 +81,36 @@ class ProductionSeeder extends Seeder
]);
}
+ if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) {
+ echo "Setting up SSH keys for non-Windows environment...\n";
+ $coolify_key_name = '@host.docker.internal';
+ $ssh_keys_directory = Storage::disk('ssh-keys')->files();
+ echo ' Found '.count($ssh_keys_directory)." SSH keys\n";
+ $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
+
+ $server = Server::find(0);
+ $found = $server->privateKey;
+ if (! $found) {
+ if ($coolify_key) {
+ echo " Found Coolify SSH key\n";
+ $user = str($coolify_key)->before('@')->after('id.');
+ $coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
+ PrivateKey::create([
+ 'id' => 0,
+ 'team_id' => 0,
+ 'name' => 'localhost\'s key',
+ 'description' => 'The private key for the Coolify host machine (localhost).',
+ 'private_key' => $coolify_key,
+ ]);
+ echo "SSH key found for the Coolify host machine (localhost).\n";
+ } else {
+ echo "No SSH key found for the Coolify host machine (localhost).\n";
+ echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n";
+ echo "Your localhost connection won't work until then.";
+ }
+ }
+ }
+
// Add Coolify host (localhost) as Server if it doesn't exist
if (! isCloud()) {
echo "Setting up localhost server...\n";
@@ -88,7 +120,7 @@ class ProductionSeeder extends Seeder
'id' => 0,
'name' => 'localhost',
'description' => "This is the server where Coolify is running on. Don't delete this!",
- 'user' => 'root',
+ 'user' => $user,
'ip' => 'host.docker.internal',
'team_id' => 0,
'private_key_id' => 0,
@@ -121,37 +153,6 @@ class ProductionSeeder extends Seeder
}
}
- if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) {
- echo "Setting up SSH keys for non-Windows environment...\n";
- $coolify_key_name = '@host.docker.internal';
- $ssh_keys_directory = Storage::disk('ssh-keys')->files();
- echo ' Found '.count($ssh_keys_directory)." SSH keys\n";
- $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
-
- $server = Server::find(0);
- $found = $server->privateKey;
- if (! $found) {
- if ($coolify_key) {
- echo " Found Coolify SSH key\n";
- $user = str($coolify_key)->before('@')->after('id.');
- $coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
- PrivateKey::create([
- 'id' => 0,
- 'team_id' => 0,
- 'name' => 'localhost\'s key',
- 'description' => 'The private key for the Coolify host machine (localhost).',
- 'private_key' => $coolify_key,
- ]);
- $server->update(['user' => $user]);
- echo "SSH key found for the Coolify host machine (localhost).\n";
- } else {
- echo "No SSH key found for the Coolify host machine (localhost).\n";
- echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n";
- echo "Your localhost connection won't work until then.";
- }
- }
- }
-
if (config('constants.coolify.is_windows_docker_desktop')) {
echo "Setting up Windows Docker Desktop environment...\n";
echo " Creating/updating private key\n";