Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: settings for apps and projects add: coolify version config fix: private key for private git based apps

Andras Bacsai3b191fa73e19
diff --git a/app/Models/Application.php b/app/Models/Application.php
index c0fa880679..a139bc6a8e 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -7,6 +7,15 @@ use Spatie\Activitylog\Models\Activity;
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);
diff --git a/app/Models/ApplicationSetting.php b/app/Models/ApplicationSetting.php
index d5f9b6f4ee..9acad2ae9b 100644
--- a/app/Models/ApplicationSetting.php
+++ b/app/Models/ApplicationSetting.php
@@ -6,4 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class ApplicationSetting extends Model
{
+ public function application()
+ {
+ return $this->belongsTo(Application::class);
+ }
}
diff --git a/app/Models/GithubApp.php b/app/Models/GithubApp.php
index 4d461fdc48..fd7dd07754 100644
--- a/app/Models/GithubApp.php
+++ b/app/Models/GithubApp.php
@@ -8,4 +8,8 @@ class GithubApp extends BaseModel
{
return $this->morphMany(Application::class, 'source');
}
+ public function privateKey()
+ {
+ return $this->belongsTo(PrivateKey::class);
+ }
}
diff --git a/app/Models/GitlabApp.php b/app/Models/GitlabApp.php
index 65024b3f71..ad5f658e2c 100644
--- a/app/Models/GitlabApp.php
+++ b/app/Models/GitlabApp.php
@@ -4,4 +4,8 @@ namespace App\Models;
class GitlabApp extends BaseModel
{
+ public function privateKey()
+ {
+ return $this->belongsTo(PrivateKey::class);
+ }
}
diff --git a/app/Models/Project.php b/app/Models/Project.php
index 1efe885480..1b0a71049b 100644
--- a/app/Models/Project.php
+++ b/app/Models/Project.php
@@ -4,6 +4,14 @@ namespace App\Models;
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);
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 3487238e99..984d714cd0 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -21,9 +21,11 @@ class AppServiceProvider extends ServiceProvider
*/
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') {
+
+ }
+ });
}
}
diff --git a/config/coolify.php b/config/coolify.php
new file mode 100644
index 0000000000..4c6af61d48
--- /dev/null
+++ b/config/coolify.php
@@ -0,0 +1,5 @@
+<?php
+
+return [
+ 'version' => '4.0.0-rc.1',
+];
diff --git a/database/migrations/2023_03_27_081716_create_applications_table.php b/database/migrations/2023_03_27_081716_create_applications_table.php
index 57515e4fca..701a70c17b 100644
--- a/database/migrations/2023_03_27_081716_create_applications_table.php
+++ b/database/migrations/2023_03_27_081716_create_applications_table.php
@@ -58,7 +58,6 @@ return new class extends Migration
$table->morphs('source');
$table->foreignId('environment_id');
-
$table->timestamps();
});
}
diff --git a/database/seeders/ApplicationSeeder.php b/database/seeders/ApplicationSeeder.php
index 91b9548340..ccfa740450 100644
--- a/database/seeders/ApplicationSeeder.php
+++ b/database/seeders/ApplicationSeeder.php
@@ -22,6 +22,7 @@ class ApplicationSeeder extends Seeder
$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 @@ class ApplicationSeeder extends Seeder
'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,
+ ]);
}
}
diff --git a/database/seeders/ApplicationSettingsSeeder.php b/database/seeders/ApplicationSettingsSeeder.php
index 760306b076..fceb329548 100644
--- a/database/seeders/ApplicationSettingsSeeder.php
+++ b/database/seeders/ApplicationSettingsSeeder.php
@@ -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,
+ // ]);
}
}
diff --git a/database/seeders/ProjectSettingSeeder.php b/database/seeders/ProjectSettingSeeder.php
index 050982beee..8a2eddcc13 100644
--- a/database/seeders/ProjectSettingSeeder.php
+++ b/database/seeders/ProjectSettingSeeder.php
@@ -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();
}
}