Able to backup Coolify itself

This commit is contained in:
Andras Bacsai
2023-08-11 16:13:53 +02:00
parent b7c9810461
commit 61864970c1
52 changed files with 353 additions and 409 deletions

View File

@@ -42,7 +42,7 @@ return new class extends Migration {
$table->timestamp('started_at')->nullable();
$table->morphs('destination');
$table->foreignId('environment_id');
$table->foreignId('environment_id')->nullable();
$table->timestamps();
});
}

View File

@@ -9,12 +9,14 @@ return new class extends Migration {
{
Schema::create('scheduled_database_backups', function (Blueprint $table) {
$table->id();
$table->text('description')->nullable();
$table->string('uuid')->unique();
$table->boolean('enabled')->default(true);
$table->string('save_s3')->default(true);
$table->boolean('save_s3')->default(true);
$table->string('frequency');
$table->integer('number_of_backups_locally')->default(7);
$table->morphs('database');
$table->foreignId('s3_storage_id')->nullable();
$table->foreignId('team_id');
$table->timestamps();
});

View File

@@ -2,7 +2,6 @@
namespace Database\Seeders;
use App\Data\ApplicationPreview;
use App\Models\Application;
use App\Models\GithubApp;
use App\Models\StandaloneDocker;
@@ -15,8 +14,6 @@ class ApplicationSeeder extends Seeder
*/
public function run(): void
{
$github_public_source = GithubApp::where('name', 'Public GitHub')->first();
Application::create([
'name' => 'coollabsio/coolify-examples:nodejs-fastify',
'description' => 'NodeJS Fastify Example',
@@ -28,9 +25,9 @@ class ApplicationSeeder extends Seeder
'ports_exposes' => '3000',
'ports_mappings' => '3000:3000',
'environment_id' => 1,
'destination_id' => 1,
'destination_id' => 0,
'destination_type' => StandaloneDocker::class,
'source_id' => $github_public_source->id,
'source_id' => 1,
'source_type' => GithubApp::class
]);
}

View File

@@ -1,23 +0,0 @@
<?php
namespace Database\Seeders;
use App\Models\Environment;
use App\Models\StandaloneDocker;
use Illuminate\Database\Seeder;
class DBSeeder extends Seeder
{
public function run(): void
{
$environment_1 = Environment::find(1);
$standalone_docker_1 = StandaloneDocker::find(1);
// Database::create([
// 'id' => 1,
// 'name'=> "My first database",
// 'environment_id' => $environment_1->id,
// 'destination_id' => $standalone_docker_1->id,
// 'destination_type' => StandaloneDocker::class,
// ]);
}
}

View File

@@ -26,8 +26,6 @@ class DatabaseSeeder extends Seeder
ApplicationSeeder::class,
ApplicationSettingsSeeder::class,
ApplicationPreviewSeeder::class,
DBSeeder::class,
ServiceSeeder::class,
EnvironmentVariableSeeder::class,
LocalPersistentVolumeSeeder::class,
S3StorageSeeder::class,

View File

@@ -2,7 +2,6 @@
namespace Database\Seeders;
use App\Models\EnvironmentVariable;
use Illuminate\Database\Seeder;
class EnvironmentVariableSeeder extends Seeder
@@ -12,11 +11,11 @@ class EnvironmentVariableSeeder extends Seeder
*/
public function run(): void
{
EnvironmentVariable::create([
'key' => 'NODE_ENV',
'value' => 'production',
'is_build_time' => true,
'application_id' => 1,
]);
// EnvironmentVariable::create([
// 'key' => 'NODE_ENV',
// 'value' => 'production',
// 'is_build_time' => true,
// 'application_id' => 1,
// ]);
}
}

View File

@@ -3,8 +3,6 @@
namespace Database\Seeders;
use App\Models\GithubApp;
use App\Models\PrivateKey;
use App\Models\Team;
use Illuminate\Database\Seeder;
class GithubAppSeeder extends Seeder
@@ -14,14 +12,12 @@ class GithubAppSeeder extends Seeder
*/
public function run(): void
{
$root_team = Team::find(0);
$private_key_2 = PrivateKey::find(1);
GithubApp::create([
'name' => 'Public GitHub',
'api_url' => 'https://api.github.com',
'html_url' => 'https://github.com',
'is_public' => true,
'team_id' => $root_team->id,
'team_id' => 0,
]);
GithubApp::create([
'name' => 'coolify-laravel-development-public',
@@ -34,8 +30,8 @@ class GithubAppSeeder extends Seeder
'client_id' => 'Iv1.220e564d2b0abd8c',
'client_secret' => '116d1d80289f378410dd70ab4e4b81dd8d2c52b6',
'webhook_secret' => '326a47b49054f03288f800d81247ec9414d0abf3',
'private_key_id' => $private_key_2->id,
'team_id' => $root_team->id,
'private_key_id' => 1,
'team_id' => 0,
]);
}
}

View File

@@ -3,8 +3,6 @@
namespace Database\Seeders;
use App\Models\GitlabApp;
use App\Models\PrivateKey;
use App\Models\Team;
use Illuminate\Database\Seeder;
class GitlabAppSeeder extends Seeder
@@ -14,15 +12,13 @@ class GitlabAppSeeder extends Seeder
*/
public function run(): void
{
$root_team = Team::find(0);
$private_key_2 = PrivateKey::find(2);
GitlabApp::create([
'id' => 1,
'name' => 'Public GitLab',
'api_url' => 'https://gitlab.com/api/v4',
'html_url' => 'https://gitlab.com',
'is_public' => true,
'team_id' => $root_team->id,
'team_id' => 0,
]);
GitlabApp::create([
'id' => 2,
@@ -35,8 +31,8 @@ class GitlabAppSeeder extends Seeder
'deploy_key_id' => '1234',
'public_key' => 'dfjasiourj',
'webhook_token' => '4u3928u4y392',
'private_key_id' => $private_key_2->id,
'team_id' => $root_team->id,
'private_key_id' => 2,
'team_id' => 0
]);
}
}

View File

@@ -3,7 +3,6 @@
namespace Database\Seeders;
use App\Models\PrivateKey;
use App\Models\Team;
use Illuminate\Database\Seeder;
class PrivateKeySeeder extends Seeder
@@ -13,10 +12,9 @@ class PrivateKeySeeder extends Seeder
*/
public function run(): void
{
$team_1 = Team::find(0);
PrivateKey::create([
"id" => 0,
"team_id" => $team_1->id,
"team_id" => 0,
"name" => "Testing-host",
"description" => "This is a test docker container",
"private_key" => "-----BEGIN OPENSSH PRIVATE KEY-----
@@ -30,7 +28,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
]);
PrivateKey::create([
"team_id" => $team_1->id,
"team_id" => 0,
"name" => "development-github-app",
"description" => "This is the key for using the development GitHub app",
"private_key" => "-----BEGIN RSA PRIVATE KEY-----
@@ -63,7 +61,7 @@ a1C8EDKapCw5hAhizEFOUQKOygL8Ipn+tmEUkORYdZ8Q8cWFCv9nIw==
"is_git_related" => true
]);
PrivateKey::create([
"team_id" => $team_1->id,
"team_id" => 0,
"name" => "development-gitlab-app",
"description" => "This is the key for using the development Gitlab app",
"private_key" => "asdf"

View File

@@ -3,18 +3,16 @@
namespace Database\Seeders;
use App\Models\Project;
use App\Models\Team;
use Illuminate\Database\Seeder;
class ProjectSeeder extends Seeder
{
public function run(): void
{
$root_team = Team::find(0);
Project::create([
'name' => "My first project",
'description' => "This is a test project in development",
'team_id' => $root_team->id,
'team_id' => 0,
]);
}
}

View File

@@ -2,15 +2,14 @@
namespace Database\Seeders;
use App\Models\Project;
use Illuminate\Database\Seeder;
class ProjectSettingSeeder extends Seeder
{
public function run(): void
{
$first_project = Project::find(1);
// $first_project = Project::find(1);
// $first_project->settings->wildcard_domain = 'wildcard.example.com';
$first_project->settings->save();
// $first_project->settings->save();
}
}

View File

@@ -18,6 +18,15 @@ class ScheduledDatabaseBackupSeeder extends Seeder
'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,
]);
}

View File

@@ -2,36 +2,24 @@
namespace Database\Seeders;
use App\Models\PrivateKey;
use App\Models\Server;
use App\Models\Team;
use Illuminate\Database\Seeder;
class ServerSeeder extends Seeder
{
public function run(): void
{
$root_team = Team::find(0);
$private_key_1 = PrivateKey::find(0);
Server::create([
'id' => 0,
'name' => "testing-local-docker-container",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host",
'team_id' => $root_team->id,
'private_key_id' => $private_key_1->id,
'team_id' => 0,
'private_key_id' => 0,
// 'proxy' => ServerMetadata::from([
// 'type' => ProxyTypes::TRAEFIK_V2->value,
// 'status' => ProxyStatus::EXITED->value
// ]),
]);
Server::create([
'name' => "testing-local-docker-container-2",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host-2",
'team_id' => $root_team->id,
'private_key_id' => $private_key_1->id
]);
}
}

View File

@@ -18,11 +18,5 @@ class ServerSettingSeeder extends Seeder
$server_2->settings->is_usable = true;
$server_2->settings->is_reachable = true;
$server_2->settings->save();
$server_3 = Server::find(1)->load(['settings']);
$server_3->settings->is_part_of_swarm = false;
$server_2->settings->is_usable = false;
$server_3->settings->is_reachable = false;
$server_3->settings->save();
}
}

View File

@@ -1,26 +0,0 @@
<?php
namespace Database\Seeders;
use App\Models\Environment;
use App\Models\StandaloneDocker;
use Illuminate\Database\Seeder;
class ServiceSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$environment_1 = Environment::find(1);
$standalone_docker_1 = StandaloneDocker::find(1);
// Service::create([
// 'id' => 1,
// 'name'=> "My first service",
// 'environment_id' => $environment_1->id,
// 'destination_id' => $standalone_docker_1->id,
// 'destination_type' => StandaloneDocker::class,
// ]);
}
}

View File

@@ -3,7 +3,6 @@
namespace Database\Seeders;
use App\Models\Destination;
use App\Models\Server;
use App\Models\StandaloneDocker;
use Illuminate\Database\Seeder;
@@ -14,11 +13,11 @@ class StandaloneDockerSeeder extends Seeder
*/
public function run(): void
{
$server_1 = Server::find(0);
StandaloneDocker::create([
'id' => 0,
'name' => 'Standalone Docker 1',
'network' => 'coolify',
'server_id' => $server_1->id,
'server_id' => 0,
]);
}
}

View File

@@ -15,7 +15,7 @@ class StandalonePostgresqlSeeder extends Seeder
'description' => 'Local PostgreSQL for testing',
'postgres_password' => 'postgres',
'environment_id' => 1,
'destination_id' => 1,
'destination_id' => 0,
'destination_type' => StandaloneDocker::class,
]);
}

View File

@@ -3,7 +3,6 @@
namespace Database\Seeders;
use App\Models\Destination;
use App\Models\Server;
use App\Models\SwarmDocker;
use Illuminate\Database\Seeder;
@@ -14,10 +13,9 @@ class SwarmDockerSeeder extends Seeder
*/
public function run(): void
{
$server_2 = Server::find(1);
SwarmDocker::create([
'name' => 'Swarm Docker 1',
'server_id' => $server_2->id,
'server_id' => 1,
]);
}
}