Merge branch 'v4-next' into notifications

This commit is contained in:
Andras Bacsai
2023-06-01 08:22:07 +02:00
204 changed files with 5744 additions and 2545 deletions

View File

@@ -18,7 +18,6 @@ class UserFactory extends Factory
public function definition(): array
{
return [
'name' => fake()->name(),
'uuid' => Str::uuid(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),

View File

@@ -15,7 +15,7 @@ return new class extends Migration
$table->id();
$table->string('uuid')->unique();
$table->boolean('is_root_user')->default(false);
$table->string('name');
$table->string('name')->default('Your Name Here');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');

View File

@@ -9,7 +9,7 @@ class CreateActivityLogTable extends Migration
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->id();
$table->string('log_name')->nullable();
$table->text('description');
$table->nullableMorphs('subject', 'subject');

View File

@@ -15,16 +15,15 @@ return new class extends Migration
$table->id();
$table->string('fqdn')->nullable();
$table->string('wildcard_domain')->nullable();
$table->string('redirect_url')->nullable();
// $table->string('preview_domain_separator')->default('.');
$table->string('default_redirect_404')->nullable();
$table->integer('public_port_min')->default(9000);
$table->integer('public_port_max')->default(9100);
// $table->string('custom_dns_servers')->default('1.1.1.1,8.8.8.8');
$table->boolean('do_not_track')->default(false);
$table->boolean('is_auto_update_enabled')->default(true);
// $table->boolean('is_dns_check_enabled')->default(true);
$table->boolean('is_registration_enabled')->default(true);
$table->boolean('is_https_forced')->default(true);
// $table->string('custom_dns_servers')->default('1.1.1.1,8.8.8.8');
// $table->string('preview_domain_separator')->default('.');
// $table->boolean('is_dns_check_enabled')->default(true);
$table->timestamps();
});
}

View File

@@ -41,8 +41,6 @@ return new class extends Migration
$table->string('base_directory')->default('/');
$table->string('publish_directory')->nullable();
$table->schemalessAttributes('previews');
$table->string('health_check_path')->default('/');
$table->string('health_check_port')->nullable();
$table->string('health_check_host')->default('localhost');
@@ -59,13 +57,13 @@ return new class extends Migration
$table->string('limits_memory_swap')->default("0");
$table->integer('limits_memory_swappiness')->default(60);
$table->string('limits_memory_reservation')->default("0");
$table->boolean('limits_memory_oom_kill')->default(false);
$table->string('limits_cpus')->default("0");
$table->string('limits_cpuset')->nullable()->default("0");
$table->integer('limits_cpu_shares')->default(1024);
$table->string('status')->default('exited');
$table->string('preview_url_template')->default('{{pr_id}}.{{domain}}');
$table->nullableMorphs('destination');
$table->nullableMorphs('source');

View File

@@ -14,14 +14,15 @@ return new class extends Migration
Schema::create('application_settings', function (Blueprint $table) {
$table->id();
$table->boolean('is_static')->default(false);
$table->boolean('is_git_submodules_allowed')->default(true);
$table->boolean('is_git_lfs_allowed')->default(true);
$table->boolean('is_auto_deploy')->default(true);
$table->boolean('is_dual_cert')->default(false);
$table->boolean('is_debug')->default(false);
$table->boolean('is_previews')->default(false);
$table->boolean('is_custom_ssl')->default(false);
$table->boolean('is_http2')->default(false);
$table->boolean('is_git_submodules_enabled')->default(true);
$table->boolean('is_git_lfs_enabled')->default(true);
$table->boolean('is_auto_deploy_enabled')->default(true);
$table->boolean('is_force_https_enabled')->default(true);
$table->boolean('is_debug_enabled')->default(false);
$table->boolean('is_preview_deployments_enabled')->default(false);
// $table->boolean('is_dual_cert')->default(false);
// $table->boolean('is_custom_ssl')->default(false);
// $table->boolean('is_http2')->default(false);
$table->foreignId('application_id');
$table->timestamps();
});

View File

@@ -0,0 +1,35 @@
<?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('application_previews', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->integer('pull_request_id');
$table->string('pull_request_html_url');
$table->string('fqdn')->unique()->nullable();
$table->string('status')->default('exited');
$table->foreignId('application_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('application_previews');
}
};

View File

@@ -0,0 +1,34 @@
<?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('application_deployment_queues', function (Blueprint $table) {
$table->id();
$table->string('application_id');
$table->string('deployment_uuid')->unique();
$table->integer('pull_request_id')->default(0);
$table->boolean('force_rebuild')->default(false);
$table->string('commit')->default('HEAD');
$table->string('status')->default('queued');
$table->boolean('is_webhook')->default(false);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('application_deployment_queues');
}
};

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use App\Models\Application;
use App\Models\ApplicationPreview;
use App\Models\Environment;
use App\Models\GithubApp;
use App\Models\StandaloneDocker;
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
// ]);
}
}

View File

@@ -26,6 +26,7 @@ class ApplicationSeeder extends Seeder
Application::create([
'name' => 'coollabsio/coolify-examples:nodejs-fastify',
'fqdn' => 'http://foo.com',
'repository_project_id' => 603035348,
'git_repository' => 'coollabsio/coolify-examples',
'git_branch' => 'nodejs-fastify',
@@ -36,17 +37,7 @@ class ApplicationSeeder extends Seeder
'destination_id' => $standalone_docker_1->id,
'destination_type' => StandaloneDocker::class,
'source_id' => $github_public_source->id,
'source_type' => GithubApp::class,
'previews' => [
ApplicationPreview::from([
'pullRequestId' => 1,
'branch' => 'nodejs-fastify'
]),
ApplicationPreview::from([
'pullRequestId' => 2,
'branch' => 'nodejs-fastify'
])
]
'source_type' => GithubApp::class
]);
}
}

View File

@@ -18,7 +18,7 @@ class ApplicationSettingsSeeder extends Seeder
public function run(): void
{
$application_1 = Application::find(1)->load(['settings']);
$application_1->settings->is_debug = false;
$application_1->settings->is_debug_enabled = false;
$application_1->settings->save();
}
}

View File

@@ -26,6 +26,7 @@ class DatabaseSeeder extends Seeder
GitlabAppSeeder::class,
ApplicationSeeder::class,
ApplicationSettingsSeeder::class,
ApplicationPreviewSeeder::class,
DBSeeder::class,
ServiceSeeder::class,
EnvironmentVariableSeeder::class,

View File

@@ -14,7 +14,6 @@ class InstanceSettingsSeeder extends Seeder
{
InstanceSettings::create([
'id' => 0,
'is_https_forced' => false,
'is_registration_enabled' => true,
]);
}

View File

@@ -2,12 +2,15 @@
namespace Database\Seeders;
use App\Data\ServerMetadata;
use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use App\Models\GithubApp;
use App\Models\GitlabApp;
use App\Models\InstanceSettings;
use App\Models\PrivateKey;
use App\Models\Project;
use App\Models\Server;
use App\Models\StandaloneDocker;
use App\Models\Team;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
@@ -53,7 +56,7 @@ class ProductionSeeder extends Seeder
// Save SSH Keys for the Coolify Host
$coolify_key_name = "id.root@host.docker.internal";
$coolify_key = Storage::disk('local')->get("ssh-keys/{$coolify_key_name}");
$coolify_key = Storage::disk('ssh-keys')->get("{$coolify_key_name}");
if ($coolify_key) {
$private_key = PrivateKey::find(0);
@@ -72,23 +75,37 @@ class ProductionSeeder extends Seeder
} else {
// TODO: Add a command to generate a new SSH key for the Coolify host machine (localhost).
echo "No SSH key found for the Coolify host machine (localhost).\n";
echo "Please generate one and save it in storage/app/ssh-keys/{$coolify_key_name}\n";
exit(1);
echo "Please generate one and save it in storage/app/ssh/keys/{$coolify_key_name}\n";
}
// Add Coolify host (localhost) as Server if it doesn't exist
if (Server::find(0) == null) {
$server = Server::create([
$server_details = [
'id' => 0,
'name' => "localhost",
'description' => "This is the local machine",
'description' => "This is the server where Coolify is running on. Don't delete this!",
'user' => 'root',
'ip' => "host.docker.internal",
'team_id' => 0,
'private_key_id' => 0,
]);
'private_key_id' => 0
];
if (env('COOLIFY_DEFAULT_PROXY') == 'traefik') {
$server_details['extra_attributes'] = ServerMetadata::from([
'proxy_type' => ProxyTypes::TRAEFIK_V2->value,
'proxy_status' => ProxyStatus::EXITED->value
]);
}
$server = Server::create($server_details);
$server->settings->is_validated = true;
$server->settings->save();
}
if (StandaloneDocker::find(0) == null) {
StandaloneDocker::create([
'id' => 0,
'name' => 'localhost-coolify',
'network' => 'coolify',
'server_id' => 0,
]);
}
}
}

View File

@@ -11,12 +11,10 @@ class UserSeeder extends Seeder
{
User::factory()->create([
"id" => 0,
'name' => 'Root User',
'email' => 'test@example.com',
'is_root_user' => true,
]);
User::factory()->create([
'name' => 'Normal User',
'email' => 'test2@example.com',
]);
}