Add production seeder
Add ssh-key custom storage
This commit is contained in:
@@ -59,9 +59,9 @@ if (!function_exists('remoteProcess')) {
|
|||||||
if (!function_exists('savePrivateKeyForServer')) {
|
if (!function_exists('savePrivateKeyForServer')) {
|
||||||
function savePrivateKeyForServer(Server $server)
|
function savePrivateKeyForServer(Server $server)
|
||||||
{
|
{
|
||||||
$temp_file = 'id.rsa_' . 'root' . '@' . $server->ip;
|
$temp_file = "id.root@{$server->ip}";
|
||||||
Storage::disk('local')->put($temp_file, $server->privateKey->private_key, 'private');
|
Storage::disk('ssh-keys')->put($temp_file, $server->privateKey->private_key, 'private');
|
||||||
return '/var/www/html/storage/app/' . $temp_file;
|
return '/var/www/html/storage/app/ssh-keys/' . $temp_file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,6 +44,22 @@ return [
|
|||||||
'throw' => false,
|
'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' => [
|
's3' => [
|
||||||
'driver' => 's3',
|
'driver' => 's3',
|
||||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
@@ -12,16 +12,19 @@ class ProductionSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$coolify_key = Storage::disk('local')->get('ssh-keys/coolify.dsa');
|
$coolify_key_name = "id.root@host.docker.internal";
|
||||||
if (PrivateKey::where('name', 'Coolify Host')->doesntExist()) {
|
$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([
|
PrivateKey::create([
|
||||||
"id" => 0,
|
'name' => 'Coolify Host',
|
||||||
"name" => "Coolify Host",
|
'description' => 'The private key for the Coolify host machine.',
|
||||||
"description" => "This is the private key for the server where Coolify is hosted.",
|
'private_key' => $coolify_key,
|
||||||
"private_key" => $coolify_key,
|
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
dump('Coolify SSH Key already exists.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user