diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index 6eaccda06..46028e545 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -59,9 +59,9 @@ function remoteProcess( if (!function_exists('savePrivateKeyForServer')) { function savePrivateKeyForServer(Server $server) { - $temp_file = 'id.rsa_' . 'root' . '@' . $server->ip; - Storage::disk('local')->put($temp_file, $server->privateKey->private_key, 'private'); - return '/var/www/html/storage/app/' . $temp_file; + $temp_file = "id.root@{$server->ip}"; + Storage::disk('ssh-keys')->put($temp_file, $server->privateKey->private_key, 'private'); + return '/var/www/html/storage/app/ssh-keys/' . $temp_file; } } diff --git a/config/filesystems.php b/config/filesystems.php index e9d9dbdbe..15c598e6b 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -44,6 +44,22 @@ 'throw' => false, ], + 'ssh-keys' => [ + 'driver' => 'local', + 'root' => storage_path('app/ssh-keys'), + 'url' => env('APP_URL').'/storage', + 'visibility' => 'private', + 'throw' => false, + ], + + 'deployments' => [ + 'driver' => 'local', + 'root' => storage_path('app/deployments'), + 'url' => env('APP_URL').'/storage', + 'visibility' => 'private', + 'throw' => false, + ], + 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index c959294aa..5ffa9fc25 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -12,16 +12,19 @@ class ProductionSeeder extends Seeder { public function run(): void { - $coolify_key = Storage::disk('local')->get('ssh-keys/coolify.dsa'); - if (PrivateKey::where('name', 'Coolify Host')->doesntExist()) { + $coolify_key_name = "id.root@host.docker.internal"; + $coolify_key = Storage::disk('local')->get("ssh-keys/{$coolify_key_name}"); + $coolify_key_in_database = PrivateKey::where('name', 'Coolify Host'); + + if (!$coolify_key && $coolify_key_in_database->exists()) { + Storage::disk('local')->put("ssh-keys/{$coolify_key_name}", $coolify_key_in_database->first()->private_key); + } + if ($coolify_key && !$coolify_key_in_database->exists()) { PrivateKey::create([ - "id" => 0, - "name" => "Coolify Host", - "description" => "This is the private key for the server where Coolify is hosted.", - "private_key" => $coolify_key, + 'name' => 'Coolify Host', + 'description' => 'The private key for the Coolify host machine.', + 'private_key' => $coolify_key, ]); - } else { - dump('Coolify SSH Key already exists.'); } } }