Merge remote-tracking branch 'origin/next' into openid-auth-support

This commit is contained in:
Andras Bacsai
2026-07-14 13:55:35 +02:00
379 changed files with 31449 additions and 2953 deletions
@@ -13,6 +13,11 @@ class CloudProviderTokenFactory extends Factory
{
protected $model = CloudProviderToken::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
@@ -0,0 +1,25 @@
<?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::table('instance_settings', function (Blueprint $table) {
$table->string('docker_registry_url')->default('docker.io')->after('is_auto_update_enabled');
});
}
public function down(): void
{
Schema::table('instance_settings', function (Blueprint $table) {
$table->dropColumn('docker_registry_url');
});
}
};
@@ -0,0 +1,44 @@
<?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
{
if (! Schema::hasColumn('servers', 'vultr_instance_id')) {
Schema::table('servers', function (Blueprint $table) {
$table->string('vultr_instance_id')->nullable()->after('hetzner_server_status');
});
}
if (! Schema::hasColumn('servers', 'vultr_instance_status')) {
Schema::table('servers', function (Blueprint $table) {
$table->string('vultr_instance_status')->nullable()->after('vultr_instance_id');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
if (Schema::hasColumn('servers', 'vultr_instance_status')) {
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn('vultr_instance_status');
});
}
if (Schema::hasColumn('servers', 'vultr_instance_id')) {
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn('vultr_instance_id');
});
}
}
};
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('teams', function (Blueprint $table) {
$table->boolean('is_mcp_server_enabled')->default(true);
});
}
public function down(): void
{
Schema::table('teams', function (Blueprint $table) {
$table->dropColumn('is_mcp_server_enabled');
});
}
};
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('instance_settings', function (Blueprint $table) {
$table->json('webhook_allowed_internal_hosts')->nullable();
$table->boolean('webhook_allow_localhost')->default(false);
});
}
public function down(): void
{
Schema::table('instance_settings', function (Blueprint $table) {
$table->dropColumn(['webhook_allowed_internal_hosts', 'webhook_allow_localhost']);
});
}
};
@@ -0,0 +1,76 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if ($this->indexExists()) {
return;
}
DB::table('tags')
->select('team_id', 'name', DB::raw('MIN(id) as keep_id'), DB::raw('COUNT(*) as tag_count'))
->whereNotNull('team_id')
->groupBy('team_id', 'name')
->havingRaw('COUNT(*) > 1')
->orderBy('keep_id')
->cursor()
->each(function ($duplicate): void {
DB::table('tags')
->select('id')
->where('team_id', $duplicate->team_id)
->where('name', $duplicate->name)
->where('id', '!=', $duplicate->keep_id)
->orderBy('id')
->cursor()
->each(function ($duplicateTag) use ($duplicate): void {
DB::table('taggables')
->where('tag_id', $duplicateTag->id)
->orderBy('taggable_id')
->cursor()
->each(function ($taggable) use ($duplicate): void {
DB::table('taggables')->updateOrInsert([
'tag_id' => $duplicate->keep_id,
'taggable_id' => $taggable->taggable_id,
'taggable_type' => $taggable->taggable_type,
]);
});
DB::table('taggables')->where('tag_id', $duplicateTag->id)->delete();
DB::table('tags')->where('id', $duplicateTag->id)->delete();
});
});
Schema::table('tags', function (Blueprint $table) {
$table->unique(['team_id', 'name'], 'tags_team_id_name_unique');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
if (! $this->indexExists()) {
return;
}
Schema::table('tags', function (Blueprint $table) {
$table->dropUnique('tags_team_id_name_unique');
});
}
private function indexExists(): bool
{
return collect(Schema::getIndexes('tags'))
->contains(fn (array $index): bool => $index['name'] === 'tags_team_id_name_unique');
}
};
@@ -0,0 +1,40 @@
<?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::table('servers', function (Blueprint $table) {
if (! Schema::hasColumn('servers', 'digitalocean_droplet_id')) {
$table->bigInteger('digitalocean_droplet_id')->nullable()->after('hetzner_server_status');
}
if (! Schema::hasColumn('servers', 'digitalocean_droplet_status')) {
$table->string('digitalocean_droplet_status')->nullable()->after('digitalocean_droplet_id');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('servers', function (Blueprint $table) {
if (Schema::hasColumn('servers', 'digitalocean_droplet_status')) {
$table->dropColumn('digitalocean_droplet_status');
}
if (Schema::hasColumn('servers', 'digitalocean_droplet_id')) {
$table->dropColumn('digitalocean_droplet_id');
}
});
}
};
@@ -0,0 +1,28 @@
<?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::table('cloud_provider_tokens', function (Blueprint $table) {
$table->text('description')->nullable()->after('name');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('cloud_provider_tokens', function (Blueprint $table) {
$table->dropColumn('description');
});
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('cloud_init_scripts', function (Blueprint $table) {
$table->string('uuid')->nullable()->unique()->after('id');
});
DB::table('cloud_init_scripts')
->whereNull('uuid')
->lazyById()
->each(function (object $script): void {
DB::table('cloud_init_scripts')
->where('id', $script->id)
->update(['uuid' => new_public_id()]);
});
}
public function down(): void
{
Schema::table('cloud_init_scripts', function (Blueprint $table) {
$table->dropUnique(['uuid']);
$table->dropColumn('uuid');
});
}
};
@@ -20,14 +20,33 @@ class DevelopmentRailpackExamplesSeeder extends Seeder
{
public const PROJECT_UUID = 'railpack-examples';
public const ENVIRONMENT_UUID = 'railpack-examples-production';
public const GIT_REPOSITORY = 'coollabsio/coolify-examples';
public const GIT_BRANCH = 'next';
public const REPOSITORY_PROJECT_ID = 603035348;
public const LIMA_SERVERS = [
[
'server_uuid' => 'lima-ubuntu-2404',
'server_name' => 'lima-ubuntu-2404',
'port' => 2222,
'environment_name' => 'ubuntu24',
'environment_uuid' => 'railpack-examples-ubuntu24',
'uuid_prefix' => 'ubuntu24-',
],
[
'server_uuid' => 'lima-ubuntu-2604',
'server_name' => 'lima-ubuntu-2604',
'port' => 2223,
'environment_name' => 'ubuntu26',
'environment_uuid' => 'railpack-examples-ubuntu26',
'uuid_prefix' => 'ubuntu26-',
],
];
private const LIMA_SENTINEL_URL = 'http://host.lima.internal:8000';
public function run(): void
{
if (! $this->isDevelopmentEnvironment()) {
@@ -37,16 +56,22 @@ class DevelopmentRailpackExamplesSeeder extends Seeder
}
$this->ensureDevelopmentPrerequisitesExist();
$destination = StandaloneDocker::query()->find(0);
if (! $destination) {
if (! StandaloneDocker::query()->find(0)) {
throw new RuntimeException('StandaloneDocker with id=0 is required before running DevelopmentRailpackExamplesSeeder.');
}
$environment = $this->prepareEnvironment();
$this->cleanupLegacyLimaProjects();
$this->cleanupLegacyProductionExamples();
foreach (self::examples() as $example) {
$this->upsertApplication($environment, $destination, $example);
foreach (self::LIMA_SERVERS as $limaServer) {
$this->seedEnvironment(
environmentUuid: $limaServer['environment_uuid'],
environmentName: $limaServer['environment_name'],
destination: $this->limaDestination($limaServer['server_uuid']),
uuidPrefix: $limaServer['uuid_prefix'],
nameSuffix: " ({$limaServer['environment_name']})",
);
}
}
@@ -440,6 +465,37 @@ KEY,
],
);
foreach (self::LIMA_SERVERS as $limaServer) {
$server = Server::query()->firstOrCreate(
['uuid' => $limaServer['server_uuid']],
[
'name' => $limaServer['server_name'],
'description' => 'This is a Lima VM for local development testing',
'ip' => 'host.docker.internal',
'port' => $limaServer['port'],
'team_id' => 0,
'private_key_id' => 1,
'proxy' => [
'type' => ProxyTypes::TRAEFIK->value,
'status' => ProxyStatus::EXITED->value,
],
],
);
$server->settings->forceFill([
'sentinel_custom_url' => self::LIMA_SENTINEL_URL,
])->saveQuietly();
StandaloneDocker::query()->firstOrCreate(
['server_id' => $server->id],
[
'uuid' => "{$limaServer['server_uuid']}-docker",
'name' => "{$limaServer['server_name']} Docker",
'network' => 'coolify',
],
);
}
StandaloneDocker::query()->firstOrCreate(
['id' => 0],
[
@@ -489,7 +545,71 @@ KEY,
return in_array(config('app.env'), ['local', 'development', 'dev'], true);
}
private function prepareEnvironment(): Environment
private function limaDestination(string $serverUuid): StandaloneDocker
{
$limaDestination = Server::query()
->where('uuid', $serverUuid)
->first()
?->standaloneDockers()
->first();
if (! $limaDestination) {
throw new RuntimeException("Lima StandaloneDocker destination is required for {$serverUuid} before running DevelopmentRailpackExamplesSeeder.");
}
return $limaDestination;
}
private function cleanupLegacyLimaProjects(): void
{
Project::query()
->whereIn('uuid', [
'railpack-examples-lima-ubuntu-2404',
'railpack-examples-lima-ubuntu-2604',
])
->get()
->each(function (Project $project): void {
Application::withTrashed()
->whereIn('environment_id', $project->environments()->pluck('id'))
->get()
->each
->forceDelete();
$project->delete();
});
}
private function cleanupLegacyProductionExamples(): void
{
$project = Project::query()->where('uuid', self::PROJECT_UUID)->first();
if (! $project) {
return;
}
Application::withTrashed()
->whereIn('environment_id', $project->environments()->pluck('id'))
->whereIn('uuid', collect(self::examples())->pluck('uuid'))
->get()
->each
->forceDelete();
}
private function seedEnvironment(
string $environmentUuid,
string $environmentName,
StandaloneDocker $destination,
string $uuidPrefix = '',
string $nameSuffix = '',
): void {
$environment = $this->prepareEnvironment($environmentUuid, $environmentName);
foreach (self::examples() as $example) {
$this->upsertApplication($environment, $destination, $example, $uuidPrefix, $nameSuffix);
}
}
private function prepareEnvironment(string $environmentUuid, string $environmentName): Environment
{
$project = Project::query()->firstOrNew(['uuid' => self::PROJECT_UUID]);
$project->fill([
@@ -499,17 +619,29 @@ KEY,
]);
$project->save();
$environment = $project->environments()->first();
$environment = $project->environments()
->where(function ($query) use ($environmentName, $environmentUuid): void {
$query
->where('name', $environmentName)
->orWhere('uuid', $environmentUuid);
})
->first();
$existingEnvironment = $project->environments()->first();
if (! $environment && $project->environments()->count() === 1 && $existingEnvironment?->name === 'production') {
$environment = $existingEnvironment;
}
if (! $environment) {
$environment = $project->environments()->create([
'name' => 'production',
'uuid' => self::ENVIRONMENT_UUID,
'name' => $environmentName,
'uuid' => $environmentUuid,
]);
} else {
$environment->update([
'name' => 'production',
'uuid' => self::ENVIRONMENT_UUID,
'name' => $environmentName,
'uuid' => $environmentUuid,
]);
}
@@ -519,13 +651,15 @@ KEY,
/**
* @param array<string, mixed> $example
*/
private function upsertApplication(Environment $environment, StandaloneDocker $destination, array $example): void
private function upsertApplication(Environment $environment, StandaloneDocker $destination, array $example, string $uuidPrefix = '', string $nameSuffix = ''): void
{
$application = Application::withTrashed()->firstOrNew(['uuid' => $example['uuid']]);
$uuid = $uuidPrefix.$example['uuid'];
$name = $example['name'].$nameSuffix;
$application = Application::withTrashed()->firstOrNew(['uuid' => $uuid]);
$application->fill([
'name' => $example['name'],
'description' => $example['name'],
'fqdn' => "http://{$example['uuid']}.127.0.0.1.sslip.io",
'name' => $name,
'description' => $name,
'fqdn' => "http://{$uuid}.127.0.0.1.sslip.io",
'repository_project_id' => $example['repository_project_id'] ?? self::REPOSITORY_PROJECT_ID,
'git_repository' => $example['git_repository'] ?? self::GIT_REPOSITORY,
'git_branch' => $example['git_branch'] ?? self::GIT_BRANCH,
+14 -2
View File
@@ -7,6 +7,11 @@ use Illuminate\Database\Seeder;
class ProjectSeeder extends Seeder
{
private const LIMA_ENVIRONMENTS = [
['name' => 'ubuntu24', 'uuid' => 'ubuntu24'],
['name' => 'ubuntu26', 'uuid' => 'ubuntu26'],
];
public function run(): void
{
$project = Project::create([
@@ -16,7 +21,14 @@ class ProjectSeeder extends Seeder
'team_id' => 0,
]);
// Update the auto-created environment with a deterministic UUID
$project->environments()->first()->update(['uuid' => 'production']);
foreach (self::LIMA_ENVIRONMENTS as $index => $environment) {
if ($index === 0) {
$project->environments()->first()->update($environment);
continue;
}
$project->environments()->create($environment);
}
}
}
+27
View File
@@ -9,6 +9,13 @@ use Illuminate\Database\Seeder;
class ServerSeeder extends Seeder
{
private const LIMA_SENTINEL_URL = 'http://host.lima.internal:8000';
private const LIMA_SERVERS = [
['uuid' => 'lima-ubuntu-2404', 'name' => 'lima-ubuntu-2404', 'port' => 2222],
['uuid' => 'lima-ubuntu-2604', 'name' => 'lima-ubuntu-2604', 'port' => 2223],
];
public function run(): void
{
Server::create([
@@ -24,5 +31,25 @@ class ServerSeeder extends Seeder
'status' => ProxyStatus::EXITED->value,
],
]);
foreach (self::LIMA_SERVERS as $limaServer) {
$server = Server::create([
'uuid' => $limaServer['uuid'],
'name' => $limaServer['name'],
'description' => 'This is a Lima VM for local development testing',
'ip' => 'host.docker.internal',
'port' => $limaServer['port'],
'team_id' => 0,
'private_key_id' => 1,
'proxy' => [
'type' => ProxyTypes::TRAEFIK->value,
'status' => ProxyStatus::EXITED->value,
],
]);
$server->settings->forceFill([
'sentinel_custom_url' => self::LIMA_SENTINEL_URL,
])->saveQuietly();
}
}
}