Merge branch 'next' into improve-cleanup
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateServerSettingsDefaultTimezone extends Migration
|
||||
{
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EncryptExistingPrivateKeys extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
try {
|
||||
DB::table('private_keys')->chunkById(100, function ($keys) {
|
||||
foreach ($keys as $key) {
|
||||
DB::table('private_keys')
|
||||
->where('id', $key->id)
|
||||
->update(['private_key' => Crypt::encryptString($key->private_key)]);
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
echo 'Encrypting private keys failed.';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddSshKeyFingerprintToPrivateKeysTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('private_keys', function (Blueprint $table) {
|
||||
$table->string('fingerprint')->after('private_key')->nullable();
|
||||
});
|
||||
|
||||
try {
|
||||
DB::table('private_keys')->chunkById(100, function ($keys) {
|
||||
foreach ($keys as $key) {
|
||||
$fingerprint = PrivateKey::generateFingerprint($key->private_key);
|
||||
if ($fingerprint) {
|
||||
$key->fingerprint = $fingerprint;
|
||||
$key->save();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
echo 'Generating fingerprints failed.';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('private_keys', function (Blueprint $table) {
|
||||
$table->dropColumn('fingerprint');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ApplicationPreviewSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $application_1 = Application::find(1);
|
||||
// ApplicationPreview::create([
|
||||
// 'application_id' => $application_1->id,
|
||||
// 'pull_request_id' => 1
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@@ -13,25 +13,18 @@ class DatabaseSeeder extends Seeder
|
||||
UserSeeder::class,
|
||||
TeamSeeder::class,
|
||||
PrivateKeySeeder::class,
|
||||
PopulateSshKeysDirectorySeeder::class,
|
||||
ServerSeeder::class,
|
||||
ServerSettingSeeder::class,
|
||||
ProjectSeeder::class,
|
||||
ProjectSettingSeeder::class,
|
||||
EnvironmentSeeder::class,
|
||||
StandaloneDockerSeeder::class,
|
||||
SwarmDockerSeeder::class,
|
||||
KubernetesSeeder::class,
|
||||
GithubAppSeeder::class,
|
||||
GitlabAppSeeder::class,
|
||||
ApplicationSeeder::class,
|
||||
ApplicationSettingsSeeder::class,
|
||||
ApplicationPreviewSeeder::class,
|
||||
EnvironmentVariableSeeder::class,
|
||||
LocalPersistentVolumeSeeder::class,
|
||||
S3StorageSeeder::class,
|
||||
StandalonePostgresqlSeeder::class,
|
||||
ScheduledDatabaseBackupSeeder::class,
|
||||
ScheduledDatabaseBackupExecutionSeeder::class,
|
||||
OauthSettingSeeder::class,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class EnvironmentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void {}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class EnvironmentVariableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// EnvironmentVariable::create([
|
||||
// 'key' => 'NODE_ENV',
|
||||
// 'value' => 'production',
|
||||
// 'is_build_time' => true,
|
||||
// 'application_id' => 1,
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Git;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class GitSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $project = Project::find(1);
|
||||
// $private_key_1 = PrivateKey::find(1);
|
||||
|
||||
// Git::create([
|
||||
// 'api_url' => 'https://api.github.com',
|
||||
// 'html_url' => 'https://github.com',
|
||||
// 'is_public' => false,
|
||||
// 'private_key_id' => $private_key_1->id,
|
||||
// 'project_id' => $project->id,
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class GithubAppSeeder extends Seeder
|
||||
'client_id' => 'Iv1.220e564d2b0abd8c',
|
||||
'client_secret' => '116d1d80289f378410dd70ab4e4b81dd8d2c52b6',
|
||||
'webhook_secret' => '326a47b49054f03288f800d81247ec9414d0abf3',
|
||||
'private_key_id' => 1,
|
||||
'private_key_id' => 2,
|
||||
'team_id' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -20,19 +20,5 @@ class GitlabAppSeeder extends Seeder
|
||||
'is_public' => true,
|
||||
'team_id' => 0,
|
||||
]);
|
||||
GitlabApp::create([
|
||||
'id' => 2,
|
||||
'name' => 'coolify-laravel-development-private-gitlab',
|
||||
'api_url' => 'https://gitlab.com/api/v4',
|
||||
'html_url' => 'https://gitlab.com',
|
||||
'app_id' => 1234,
|
||||
'app_secret' => '1234',
|
||||
'oauth_id' => 1234,
|
||||
'deploy_key_id' => '1234',
|
||||
'public_key' => 'dfjasiourj',
|
||||
'webhook_token' => '4u3928u4y392',
|
||||
'private_key_id' => 2,
|
||||
'team_id' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class KubernetesSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LocalFileVolumeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
40
database/seeders/PopulateSshKeysDirectorySeeder.php
Normal file
40
database/seeders/PopulateSshKeysDirectorySeeder.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PopulateSshKeysDirectorySeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
try {
|
||||
Storage::disk('ssh-keys')->deleteDirectory('');
|
||||
Storage::disk('ssh-keys')->makeDirectory('');
|
||||
Storage::disk('ssh-mux')->deleteDirectory('');
|
||||
Storage::disk('ssh-mux')->makeDirectory('');
|
||||
|
||||
PrivateKey::chunk(100, function ($keys) {
|
||||
foreach ($keys as $key) {
|
||||
echo 'Storing key: '.$key->name."\n";
|
||||
$key->storeInFileSystem();
|
||||
}
|
||||
});
|
||||
|
||||
if (isDev()) {
|
||||
$user = env('PUID').':'.env('PGID');
|
||||
Process::run("chown -R $user ".storage_path('app/ssh/keys'));
|
||||
Process::run("chown -R $user ".storage_path('app/ssh/mux'));
|
||||
} else {
|
||||
Process::run('chown -R 9999:root '.storage_path('app/ssh/keys'));
|
||||
Process::run('chown -R 9999:root '.storage_path('app/ssh/mux'));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: {$e->getMessage()}\n";
|
||||
ray($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,8 @@ class PrivateKeySeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
PrivateKey::create([
|
||||
'id' => 0,
|
||||
'team_id' => 0,
|
||||
'name' => 'Testing-host',
|
||||
'name' => 'Testing Host Key',
|
||||
'description' => 'This is a test docker container',
|
||||
'private_key' => '-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
@@ -25,10 +24,9 @@ AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
|
||||
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
||||
-----END OPENSSH PRIVATE KEY-----
|
||||
',
|
||||
|
||||
]);
|
||||
|
||||
PrivateKey::create([
|
||||
'id' => 1,
|
||||
'team_id' => 0,
|
||||
'name' => 'development-github-app',
|
||||
'description' => 'This is the key for using the development GitHub app',
|
||||
@@ -61,12 +59,5 @@ a1C8EDKapCw5hAhizEFOUQKOygL8Ipn+tmEUkORYdZ8Q8cWFCv9nIw==
|
||||
-----END RSA PRIVATE KEY-----',
|
||||
'is_git_related' => true,
|
||||
]);
|
||||
PrivateKey::create([
|
||||
'id' => 2,
|
||||
'team_id' => 0,
|
||||
'name' => 'development-gitlab-app',
|
||||
'description' => 'This is the key for using the development Gitlab app',
|
||||
'private_key' => 'asdf',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,32 +64,8 @@ class ProductionSeeder extends Seeder
|
||||
'team_id' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {
|
||||
echo "Checking localhost key.\n";
|
||||
// Save SSH Keys for the Coolify Host
|
||||
$coolify_key_name = 'id.root@host.docker.internal';
|
||||
$coolify_key = Storage::disk('ssh-keys')->get("{$coolify_key_name}");
|
||||
|
||||
if ($coolify_key) {
|
||||
PrivateKey::updateOrCreate(
|
||||
[
|
||||
'id' => 0,
|
||||
'team_id' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'localhost\'s key',
|
||||
'description' => 'The private key for the Coolify host machine (localhost).',
|
||||
'private_key' => $coolify_key,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
echo "No SSH key found for the Coolify host machine (localhost).\n";
|
||||
echo "Please generate one and save it in /data/coolify/ssh/keys/{$coolify_key_name}\n";
|
||||
echo "Then try to install again.\n";
|
||||
exit(1);
|
||||
}
|
||||
// Add Coolify host (localhost) as Server if it doesn't exist
|
||||
// Add Coolify host (localhost) as Server if it doesn't exist
|
||||
if (! isCloud()) {
|
||||
if (Server::find(0) == null) {
|
||||
$server_details = [
|
||||
'id' => 0,
|
||||
@@ -123,6 +99,50 @@ class ProductionSeeder extends Seeder
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {
|
||||
echo "Checking localhost key.\n";
|
||||
$coolify_key_name = '@host.docker.internal';
|
||||
$ssh_keys_directory = Storage::disk('ssh-keys')->files();
|
||||
$coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
|
||||
|
||||
$found = PrivateKey::find(0);
|
||||
if ($found) {
|
||||
echo 'Private Key found in database.\n';
|
||||
if ($coolify_key) {
|
||||
echo "SSH key found for the Coolify host machine (localhost).\n";
|
||||
}
|
||||
} else {
|
||||
if ($coolify_key) {
|
||||
$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 {
|
||||
PrivateKey::create(
|
||||
[
|
||||
'id' => 0,
|
||||
'team_id' => 0,
|
||||
'name' => 'localhost\'s key',
|
||||
'description' => 'The private key for the Coolify host machine (localhost).',
|
||||
'private_key' => 'Paste here you private key!!',
|
||||
]
|
||||
);
|
||||
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('coolify.is_windows_docker_desktop')) {
|
||||
PrivateKey::updateOrCreate(
|
||||
[
|
||||
@@ -179,8 +199,8 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
||||
|
||||
get_public_ips();
|
||||
|
||||
$oauth_settings_seeder = new OauthSettingSeeder;
|
||||
$oauth_settings_seeder->run();
|
||||
$this->call(OauthSettingSeeder::class);
|
||||
$this->call(PopulateSshKeysDirectorySeeder::class);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProjectSettingSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// $first_project = Project::find(1);
|
||||
// $first_project->settings->wildcard_domain = 'wildcard.example.com';
|
||||
// $first_project->settings->save();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\ScheduledDatabaseBackupExecution;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ScheduledDatabaseBackupExecutionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// ScheduledDatabaseBackupExecution::create([
|
||||
// 'status' => 'success',
|
||||
// 'message' => 'Backup created successfully.',
|
||||
// 'size' => '10243467789556',
|
||||
// 'scheduled_database_backup_id' => 1,
|
||||
// ]);
|
||||
// ScheduledDatabaseBackupExecution::create([
|
||||
// 'status' => 'failed',
|
||||
// 'message' => 'Backup failed.',
|
||||
// 'size' => '10243456',
|
||||
// 'scheduled_database_backup_id' => 1,
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\ScheduledDatabaseBackup;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ScheduledDatabaseBackupSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// ScheduledDatabaseBackup::create([
|
||||
// 'enabled' => true,
|
||||
// 'frequency' => '* * * * *',
|
||||
// 'number_of_backups_locally' => 2,
|
||||
// 'database_id' => 1,
|
||||
// 'database_type' => 'App\Models\StandalonePostgresql',
|
||||
// 's3_storage_id' => 1,
|
||||
// 'team_id' => 0,
|
||||
// ]);
|
||||
// ScheduledDatabaseBackup::create([
|
||||
// 'enabled' => true,
|
||||
// 'frequency' => '* * * * *',
|
||||
// 'number_of_backups_locally' => 3,
|
||||
// 'database_id' => 1,
|
||||
// 'database_type' => 'App\Models\StandalonePostgresql',
|
||||
// 'team_id' => 0,
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\ProxyStatus;
|
||||
use App\Enums\ProxyTypes;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
@@ -15,7 +17,11 @@ class ServerSeeder extends Seeder
|
||||
'description' => 'This is a test docker container in development mode',
|
||||
'ip' => 'coolify-testing-host',
|
||||
'team_id' => 0,
|
||||
'private_key_id' => 0,
|
||||
'private_key_id' => 1,
|
||||
'proxy' => [
|
||||
'type' => ProxyTypes::TRAEFIK->value,
|
||||
'status' => ProxyStatus::EXITED->value,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ServiceApplicationSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ServiceDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ServiceSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SubscriptionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\SwarmDocker;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SwarmDockerSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// SwarmDocker::create([
|
||||
// 'name' => 'Swarm Docker 1',
|
||||
// 'server_id' => 1,
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class WaitlistSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class WebhookSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user