fix: settings for apps and projects

add: coolify version config
fix: private key for private git based apps
This commit is contained in:
Andras Bacsai 2023-03-30 11:09:39 +02:00
parent 90424d9847
commit 3b191fa73e
11 changed files with 62 additions and 25 deletions

View File

@ -7,6 +7,15 @@
class Application extends BaseModel class Application extends BaseModel
{ {
protected static function booted()
{
static::created(function ($application) {
ApplicationSetting::create([
'application_id' => $application->id,
]);
});
}
public function environment() public function environment()
{ {
return $this->belongsTo(Environment::class); return $this->belongsTo(Environment::class);

View File

@ -6,4 +6,8 @@
class ApplicationSetting extends Model class ApplicationSetting extends Model
{ {
public function application()
{
return $this->belongsTo(Application::class);
}
} }

View File

@ -8,4 +8,8 @@ public function applications()
{ {
return $this->morphMany(Application::class, 'source'); return $this->morphMany(Application::class, 'source');
} }
public function privateKey()
{
return $this->belongsTo(PrivateKey::class);
}
} }

View File

@ -4,4 +4,8 @@
class GitlabApp extends BaseModel class GitlabApp extends BaseModel
{ {
public function privateKey()
{
return $this->belongsTo(PrivateKey::class);
}
} }

View File

@ -4,6 +4,14 @@
class Project extends BaseModel class Project extends BaseModel
{ {
protected static function booted()
{
static::created(function ($project) {
ProjectSetting::create([
'project_id' => $project->id,
]);
});
}
public function environments() { public function environments() {
return $this->hasMany(Environment::class); return $this->hasMany(Environment::class);
} }

View File

@ -21,9 +21,11 @@ public function register(): void
*/ */
public function boot(): void public function boot(): void
{ {
// @TODO: Should remove builder container here Queue::after(function (JobProcessed $event) {
// Queue::after(function (JobProcessed $event) { // @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`.
// dd($event->job->resolveName()); if ($event->job->resolveName() === 'App\Jobs\ExecuteRemoteProcess') {
// });
}
});
} }
} }

5
config/coolify.php Normal file
View File

@ -0,0 +1,5 @@
<?php
return [
'version' => '4.0.0-rc.1',
];

View File

@ -58,7 +58,6 @@ public function up(): void
$table->morphs('source'); $table->morphs('source');
$table->foreignId('environment_id'); $table->foreignId('environment_id');
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -22,6 +22,7 @@ public function run(): void
$swarm_docker_1 = SwarmDocker::find(1); $swarm_docker_1 = SwarmDocker::find(1);
$github_public_source = GithubApp::find(1); $github_public_source = GithubApp::find(1);
$github_private_source = GithubApp::find(2);
Application::create([ Application::create([
'id' => 1, 'id' => 1,
'name' => 'My first application', 'name' => 'My first application',
@ -36,14 +37,19 @@ public function run(): void
'source_id' => $github_public_source->id, 'source_id' => $github_public_source->id,
'source_type' => GithubApp::class, 'source_type' => GithubApp::class,
]); ]);
// Application::create([ Application::create([
// 'id' => 2, 'id' => 2,
// 'name' => 'My second application (Swarm)', 'name' => 'My second application',
// 'environment_id' => $environment_1->id, 'git_repository' => 'coollabsio/nodejs-example',
// 'destination_id' => $swarm_docker_1->id, 'git_branch' => 'main',
// 'destination_type' => SwarmDocker::class, 'build_pack' => 'nixpacks',
// 'source_id' => $github_public_source->id, 'ports_exposes' => '3000',
// 'source_type' => GithubApp::class, 'ports_mappings' => '3001:3000',
// ]); 'environment_id' => $environment_1->id,
'destination_id' => $standalone_docker_1->id,
'destination_type' => StandaloneDocker::class,
'source_id' => $github_private_source->id,
'source_type' => GithubApp::class,
]);
} }
} }

View File

@ -17,10 +17,10 @@ class ApplicationSettingsSeeder extends Seeder
*/ */
public function run(): void public function run(): void
{ {
$application_1 = Application::find(1); // $application_1 = Application::find(1);
ApplicationSetting::create([ // ApplicationSetting::create([
'id' => 1, // 'id' => 1,
'application_id' => $application_1->id, // 'application_id' => $application_1->id,
]); // ]);
} }
} }

View File

@ -3,7 +3,6 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Models\Project; use App\Models\Project;
use App\Models\ProjectSetting;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class ProjectSettingSeeder extends Seeder class ProjectSettingSeeder extends Seeder
@ -11,10 +10,7 @@ class ProjectSettingSeeder extends Seeder
public function run(): void public function run(): void
{ {
$first_project = Project::find(1); $first_project = Project::find(1);
ProjectSetting::create([ $first_project->settings->wildcard_domain = 'wildcard.example.com';
'id' => 1, $first_project->settings->save();
'wildcard_domain' => 'testing-host.localhost',
'project_id' => $first_project->id,
]);
} }
} }