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.

Add production seeder Add ssh-key custom storage

Andras Bacsai310cac8233ce
diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php
index 6eaccda066..46028e545a 100644
--- a/bootstrap/helpers.php
+++ b/bootstrap/helpers.php
@@ -59,9 +59,9 @@ if (!function_exists('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 e9d9dbdbe8..15c598e6bf 100644
--- a/config/filesystems.php
+++ b/config/filesystems.php
@@ -44,6 +44,22 @@ return [
'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 c959294aa3..5ffa9fc25c 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 = "[email protected]";
+ $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.');
}
}
}