Add Servers and PrivateKeys

Add new testhost
Remove privatekey injection from Dockerfile
This commit is contained in:
Andras Bacsai
2023-03-24 22:15:36 +01:00
parent 9e326d15b9
commit f57684b024
14 changed files with 116 additions and 38 deletions

View File

@@ -17,7 +17,7 @@ return new class extends Migration
$table->string('name');
$table->string('description')->nullable();
$table->longText('private_key');
$table->nullableMorphs('private_key_morph');
$table->nullableMorphs('private_keys_morph');
$table->timestamps();
});
}

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('private_keyables', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('private_key_id');
$table->unsignedBigInteger('private_keyable_id');
$table->string('private_keyable_type');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('private_keyables');
}
};

View File

@@ -15,16 +15,20 @@ class PrivateKeySeeder extends Seeder
public function run(): void
{
$server = Server::find(1);
PrivateKey::create([
$server2 = Server::find(2);
$private_key = PrivateKey::create([
"name" => "Testing-host",
"description" => "This is a test docker container",
"private_key" => "-----BEGIN OPENSSH PRIVATE KEY-----\
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW\
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk\
hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA\
AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV\
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==\
-----END OPENSSH PRIVATE KEY-----",
])->private_key_morph()->associate($server)->save();
"private_key" => "-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk
hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA
AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
-----END OPENSSH PRIVATE KEY-----
",
]);
$server->privateKeys()->attach($private_key);
$server2->privateKeys()->attach($private_key);
}
}

View File

@@ -22,5 +22,12 @@ class ServerSeeder extends Seeder
'ip' => "coolify-testing-host",
'team_id' => $root_team->id,
]);
Server::create([
'id' => 2,
'name' => "testing-host2",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host-2",
'team_id' => $root_team->id,
]);
}
}