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
{
protected static function booted()
{
static::created(function ($application) {
ApplicationSetting::create([
'application_id' => $application->id,
]);
});
}
public function environment()
{
return $this->belongsTo(Environment::class);

View File

@ -6,4 +6,8 @@
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');
}
public function privateKey()
{
return $this->belongsTo(PrivateKey::class);
}
}

View File

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

View File

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

View File

@ -21,9 +21,11 @@ public function register(): void
*/
public function boot(): void
{
// @TODO: Should remove builder container here
// Queue::after(function (JobProcessed $event) {
// dd($event->job->resolveName());
// });
Queue::after(function (JobProcessed $event) {
// @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`.
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->foreignId('environment_id');
$table->timestamps();
});
}

View File

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

View File

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