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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Add GitHub, GitLab, DeployKeys
Andras Bacsai54441ddfdec5
diff --git a/app/Models/Application.php b/app/Models/Application.phpindex 875a6c7900..8f8c4391b4 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -12,4 +12,8 @@ class Application extends BaseModel{return $this->morphTo();}+ public function source()+ {+ return $this->morphTo();+ }}diff --git a/app/Models/GitDeployKey.php b/app/Models/GitDeployKey.phpnew file mode 100644index 0000000000..f487f37c51--- /dev/null+++ b/app/Models/GitDeployKey.php@@ -0,0 +1,7 @@+<?php++namespace App\Models;++class GitDeployKey extends BaseModel+{+}diff --git a/app/Models/GithubApp.php b/app/Models/GithubApp.phpnew file mode 100644index 0000000000..4d461fdc48--- /dev/null+++ b/app/Models/GithubApp.php@@ -0,0 +1,11 @@+<?php++namespace App\Models;++class GithubApp extends BaseModel+{+ public function applications()+ {+ return $this->morphMany(Application::class, 'source');+ }+}diff --git a/app/Models/GitlabApp.php b/app/Models/GitlabApp.phpnew file mode 100644index 0000000000..65024b3f71--- /dev/null+++ b/app/Models/GitlabApp.php@@ -0,0 +1,7 @@+<?php++namespace App\Models;++class GitlabApp extends BaseModel+{+}diff --git a/app/Models/Kubernetes.php b/app/Models/Kubernetes.phpindex fe2e65ca82..2ad7a21103 100644--- a/app/Models/Kubernetes.php+++ b/app/Models/Kubernetes.php@@ -2,10 +2,6 @@namespace App\Models;-use Illuminate\Database\Eloquent\Factories\HasFactory;-use Illuminate\Database\Eloquent\Model;--class Kubernetes extends Model+class Kubernetes extends BaseModel{- use HasFactory;}diff --git a/database/migrations/2023_03_27_081716_create_applications_table.php b/database/migrations/2023_03_27_081716_create_applications_table.phpindex c5a2570e5c..5e86f09ce3 100644--- a/database/migrations/2023_03_27_081716_create_applications_table.php+++ b/database/migrations/2023_03_27_081716_create_applications_table.php@@ -17,6 +17,7 @@ return new class extends Migration$table->string('name');$table->morphs('destination');+ $table->morphs('source');$table->foreignId('environment_id');$table->timestamps();diff --git a/database/migrations/2023_03_27_085022_create_standalone_dockers_table.php b/database/migrations/2023_03_27_085020_create_standalone_dockers_table.phpsimilarity index 100%rename from database/migrations/2023_03_27_085022_create_standalone_dockers_table.phprename to database/migrations/2023_03_27_085020_create_standalone_dockers_table.phpdiff --git a/database/migrations/2023_03_27_085023_create_swarm_dockers_table.php b/database/migrations/2023_03_27_085022_create_swarm_dockers_table.phpsimilarity index 100%rename from database/migrations/2023_03_27_085023_create_swarm_dockers_table.phprename to database/migrations/2023_03_27_085022_create_swarm_dockers_table.phpdiff --git a/database/migrations/2023_03_28_062150_create_kubernetes_table.php b/database/migrations/2023_03_28_062150_create_kubernetes_table.phpindex 42ef4770a2..365380e1fc 100644--- a/database/migrations/2023_03_28_062150_create_kubernetes_table.php+++ b/database/migrations/2023_03_28_062150_create_kubernetes_table.php@@ -13,6 +13,8 @@ return new class extends Migration{Schema::create('kubernetes', function (Blueprint $table) {$table->id();+ $table->string('uuid')->unique();+$table->timestamps();});}diff --git a/database/migrations/2023_03_28_083723_create_github_apps_table.php b/database/migrations/2023_03_28_083723_create_github_apps_table.phpnew file mode 100644index 0000000000..049c8f3661--- /dev/null+++ b/database/migrations/2023_03_28_083723_create_github_apps_table.php@@ -0,0 +1,46 @@+<?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('github_apps', function (Blueprint $table) {+ $table->id();+ $table->string('uuid')->unique();+ $table->string('name');++ $table->string('organization')->nullable();+ $table->string('api_url');+ $table->string('html_url');+ $table->integer('custom_port')->default(22);+ $table->string('custom_user')->default('git');+ $table->boolean('is_system_wide')->default(false);+ $table->boolean('is_public')->default(false);++ $table->integer('app_id')->nullable();+ $table->integer('installation_id')->nullable();+ $table->string('client_id')->nullable();+ $table->longText('client_secret')->nullable();+ $table->longText('webhook_secret')->nullable();++ $table->foreignId('private_key_id')->nullable();+ $table->foreignId('team_id');+ $table->timestamps();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::dropIfExists('github_apps');+ }+};diff --git a/database/migrations/2023_03_28_083726_create_gitlab_apps_table.php b/database/migrations/2023_03_28_083726_create_gitlab_apps_table.phpnew file mode 100644index 0000000000..24db88d863--- /dev/null+++ b/database/migrations/2023_03_28_083726_create_gitlab_apps_table.php@@ -0,0 +1,49 @@+<?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('gitlab_apps', function (Blueprint $table) {+ $table->id();+ $table->string('uuid')->unique();+ $table->string('name');++ $table->string('organization')->nullable();+ $table->string('api_url');+ $table->string('html_url');+ $table->integer('custom_port')->default(22);+ $table->string('custom_user')->default('git');+ $table->boolean('is_system_wide')->default(false);+ $table->boolean('is_public')->default(false);++ $table->integer('app_id')->nullable();+ $table->string('app_secret')->nullable();+ $table->integer('oauth_id')->nullable();+ $table->string('group_name')->nullable();+ $table->longText('public_key')->nullable();+ $table->longText('webhook_token')->nullable();+ $table->integer('deploy_key_id')->nullable();++ $table->foreignId('private_key_id')->nullable();+ $table->foreignId('team_id');++ $table->timestamps();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::dropIfExists('gitlab_apps');+ }+};diff --git a/database/migrations/2023_03_28_100003_create_git_deploy_keys_table.php b/database/migrations/2023_03_28_100003_create_git_deploy_keys_table.phpnew file mode 100644index 0000000000..0f22aa97e2--- /dev/null+++ b/database/migrations/2023_03_28_100003_create_git_deploy_keys_table.php@@ -0,0 +1,31 @@+<?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('git_deploy_keys', function (Blueprint $table) {+ $table->id();+ $table->string('uuid')->unique();+ $table->string('url');++ $table->foreignId('private_key_id');+ $table->timestamps();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::dropIfExists('git_deploy_keys');+ }+};diff --git a/database/seeders/ApplicationSeeder.php b/database/seeders/ApplicationSeeder.phpindex ded229b65b..6436edeef6 100644--- a/database/seeders/ApplicationSeeder.php+++ b/database/seeders/ApplicationSeeder.php@@ -4,6 +4,7 @@ namespace Database\Seeders;use App\Models\Application;use App\Models\Environment;+use App\Models\GithubApp;use App\Models\StandaloneDocker;use App\Models\SwarmDocker;use Illuminate\Database\Seeder;@@ -19,12 +20,15 @@ class ApplicationSeeder extends Seeder$standalone_docker_1 = StandaloneDocker::find(1);$swarm_docker_1 = SwarmDocker::find(1);+ $github_public_source = GithubApp::find(1);Application::create(['id' => 1,'name' => 'My first application','environment_id' => $environment_1->id,'destination_id' => $standalone_docker_1->id,'destination_type' => StandaloneDocker::class,+ 'source_id' => $github_public_source->id,+ 'source_type' => GithubApp::class,]);Application::create(['id' => 2,@@ -32,6 +36,8 @@ class ApplicationSeeder extends Seeder'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,]);}}diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.phpindex 674153fd0b..c2bf8ac21c 100644--- a/database/seeders/DatabaseSeeder.php+++ b/database/seeders/DatabaseSeeder.php@@ -2,29 +2,28 @@namespace Database\Seeders;-use App\Models\StandaloneDocker;use Illuminate\Database\Seeder;class DatabaseSeeder extends Seeder{public function run(): void{- if (env('APP_ENV') === 'local') {- $this->call([- UserSeeder::class,- TeamSeeder::class,- PrivateKeySeeder::class,- ServerSeeder::class,- ProjectSeeder::class,- ProjectSettingSeeder::class,- EnvironmentSeeder::class,- StandaloneDockerSeeder::class,- SwarmDockerSeeder::class,- KubernetesSeeder::class,- ApplicationSeeder::class,- DBSeeder::class,- ServiceSeeder::class,- ]);- }+ $this->call([+ UserSeeder::class,+ TeamSeeder::class,+ PrivateKeySeeder::class,+ ServerSeeder::class,+ ProjectSeeder::class,+ ProjectSettingSeeder::class,+ EnvironmentSeeder::class,+ StandaloneDockerSeeder::class,+ SwarmDockerSeeder::class,+ KubernetesSeeder::class,+ GithubAppSeeder::class,+ GitlabAppSeeder::class,+ ApplicationSeeder::class,+ DBSeeder::class,+ ServiceSeeder::class,+ ]);}}diff --git a/database/seeders/GitDeployKeySeeder.php b/database/seeders/GitDeployKeySeeder.phpnew file mode 100644index 0000000000..ecbcb56538--- /dev/null+++ b/database/seeders/GitDeployKeySeeder.php@@ -0,0 +1,17 @@+<?php++namespace Database\Seeders;++use Illuminate\Database\Console\Seeds\WithoutModelEvents;+use Illuminate\Database\Seeder;++class GitDeployKeySeeder extends Seeder+{+ /**+ * Run the database seeds.+ */+ public function run(): void+ {+ //+ }+}diff --git a/database/seeders/GithubAppSeeder.php b/database/seeders/GithubAppSeeder.phpnew file mode 100644index 0000000000..d2b587f7ee--- /dev/null+++ b/database/seeders/GithubAppSeeder.php@@ -0,0 +1,43 @@+<?php++namespace Database\Seeders;++use App\Models\GithubApp;+use App\Models\PrivateKey;+use App\Models\Team;+use Illuminate\Database\Console\Seeds\WithoutModelEvents;+use Illuminate\Database\Seeder;++class GithubAppSeeder extends Seeder+{+ /**+ * Run the database seeds.+ */+ public function run(): void+ {+ $root_team = Team::find(1);+ $private_key_2 = PrivateKey::find(2);+ GithubApp::create([+ 'id' => 1,+ 'name' => 'Public GitHub',+ 'api_url' => 'https://api.github.com',+ 'html_url' => 'https://github.com',+ 'is_public' => true,+ 'team_id' => $root_team->id,+ ]);+ GithubApp::create([+ 'id' => 2,+ 'name' => 'coolify-laravel-development-private-github',+ 'api_url' => 'https://api.github.com',+ 'html_url' => 'https://github.com',+ 'is_public' => false,+ 'app_id' => 292941,+ 'installation_id' => 34157139,+ 'client_id' => 'Iv1.220e564d2b0abd8c',+ 'client_secret' => '96b1b31f36ce0a34386d11798ff35b9b6d8aba3a',+ 'webhook_secret' => '326a47b49054f03288f800d81247ec9414d0abf3',+ 'private_key_id' => $private_key_2->id,+ 'team_id' => $root_team->id,+ ]);+ }+}diff --git a/database/seeders/GitlabAppSeeder.php b/database/seeders/GitlabAppSeeder.phpnew file mode 100644index 0000000000..92da014a7b--- /dev/null+++ b/database/seeders/GitlabAppSeeder.php@@ -0,0 +1,43 @@+<?php++namespace Database\Seeders;++use App\Models\GitlabApp;+use App\Models\PrivateKey;+use App\Models\Team;+use Illuminate\Database\Console\Seeds\WithoutModelEvents;+use Illuminate\Database\Seeder;++class GitlabAppSeeder extends Seeder+{+ /**+ * Run the database seeds.+ */+ public function run(): void+ {+ $root_team = Team::find(1);+ $private_key_3 = PrivateKey::find(3);+ GitlabApp::create([+ 'id' => 1,+ 'name' => 'Public GitLab',+ 'api_url' => 'https://gitlab.com/api/v4',+ 'html_url' => 'https://gitlab.com',+ 'is_public' => true,+ 'team_id' => $root_team->id,+ ]);+ GitlabApp::create([+ 'id' => 2,+ 'name' => 'coolify-laravel-development-private-gitlab',+ 'api_url' => 'https://gitlab.com/api/v4',+ 'html_url' => 'https://gitlab.com',+ 'app_id' => 1234,+ 'app_secret' => '1234',+ 'oauth_id' => 1234,+ 'deploy_key_id' => '1234',+ 'public_key' => 'dfjasiourj',+ 'webhook_token' => '4u3928u4y392',+ 'private_key_id' => $private_key_3->id,+ 'team_id' => $root_team->id,+ ]);+ }+}diff --git a/database/seeders/PrivateKeySeeder.php b/database/seeders/PrivateKeySeeder.phpindex 554d949e72..b54a07f6b6 100644--- a/database/seeders/PrivateKeySeeder.php+++ b/database/seeders/PrivateKeySeeder.php@@ -15,6 +15,7 @@ class PrivateKeySeeder extends Seederpublic function run(): void{PrivateKey::create([+ "id" => 1,"name" => "Testing-host","description" => "This is a test docker container","private_key" => "-----BEGIN OPENSSH PRIVATE KEY-----@@ -26,5 +27,43 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==-----END OPENSSH PRIVATE KEY-----"]);+ PrivateKey::create([+ "id" => 2,+ "name" => "development-github-app",+ "description" => "This is the key for using the development GitHub app",+ "private_key" => "-----BEGIN RSA PRIVATE KEY-----+MIIEpAIBAAKCAQEAstJo/SfYh3tquc2BA29a1X3pdPpXazRgtKsb5fHOwQs1rE04+VyJYW6QCToSH4WS1oKt6iI4ma4uivn8rnkZFdw3mpcLp2ofcoeV3YPKX6pN/RiJC+if+g8gCaFywOxy2pjXOLPZeFJSXFqc4UOymbhESUyDnMfk4/RvnubMiv3jINo4Ow+4Tv7tRzAdMlMrx3hEhi142oQuyl1kc4WQOM9cAV0bd+62ga3EYSnsWTnC9AaFtWk+eGC5w/7knHJ5QZ9tKApkG3/29vJXY7WwCRUROEHqkvQhRDP0uqRPBdR48iG87Dwq+ePa6TodkFaVfyHS/OUZzRiTn6MOSyQQFg0QIIwIDAQABAoIBAQCsmGebSJU2lwl4+0oAeZ6E9hG0LagFsSL66QpkHxO9w5bflWRbzCwRLVy6eyE46XzDrJfd7y/ALR1hK+E4ZvGpY7heBDx7BdK1rprAggO6YjVD+42qJsfZ3DVo9jpDOTTWBkVcxkI1Xwd9ej+wHNIcy1WabdM1nSoyC9M+ziEKOOOShXc5Q6e+zEzSBbwjc1fvvXZOH4VXZZ1DllE+xGu0jFS23TLnXATxh8SdfYgnvfZgB5n72P9m/lj3FmkuJq57DLZhBwN3Zd4wom03+K7/J4K2Ssnjdv/HjVgrRgpMv7oMxfclN/Aiq878Ue4Mav6LjnLENyHbyR0WxQjY6+lZ7UMEeJAoGBAOCGepk3rCMFa3a6GagN6lYzAkLxB5y0PsefiDo6w+PeEj1tUvSd+aQkiP7uvUC7a5GNp9yE8W79/O1jJXYJq15kMBpUshzfgdzyzDDCj+qvm6nbTWtP9+rP30h81R+NGdOStgs0OVZSjMWnIoii3Rv3UV4+iQXZd67+wd/kbTWtWVAoGBAMvj+xv4wjt7OwtK/6oAhcNd2V9EUQp6PPpMkUyPicWdsLsoNOcuTpWvEc0AomdIGGjgI+AIor1ggCxjEhbCDaZucOFUghciUup+PjyQyQT+3bjvCWuUmi0Vt51G7RE0jjZjQt+2+W9V4yDcJ5R5ow6veYvT0ZOjVTScDYowTBulgjXAoGBALFxVl7UotQiqmVwempY+ZQSu13C0MIHl6V+2cuEiJEJn9R5a0h7EcIhpatkXmlUNZUY0Lr0ziIb1NJ/ctGwn+qDAqUuF+CXddjJ6KGm4uiiNlIZO7QaMcbqVdph3cVLrEeLQRfltBLGtr5WcnJt1D+UP5lyHK59V2MKSUAJz8uNjFpAoGAL5fR4Y/wKa5V5+AImzQzJPho81MpYd3KG4rF+JYE8O4oTOfLwZMboPEm1JWrUzSPDhwTHK3mkEmajYOCOXvTcRF8TNK0p+ef0JMwN+KDOflMRFj39/bOLmv9Wmct+3ArKiLtftlqkmAJTF+w7fJCiqH0s31A+OChi9PMcy+oV2PBC0CgYAXOm08kFOQA+bPBdLAte8Ga89frh6asH/Z8ucfsz9/zMMG/hhq5nF3+7TItY9Pblc2Fp805J13G96zWLX4YGyLwXXkYs+Ae7QoqjonTw7/mUDARY1Zxs9m/+a1C8EDKapCw5hAhizEFOUQKOygL8Ipn+tmEUkORYdZ8Q8cWFCv9nIw==+-----END RSA PRIVATE KEY-----"+ ]);+ PrivateKey::create([+ "id" => 3,+ "name" => "development-gitlab-app",+ "description" => "This is the key for using the development Gitlab app",+ "private_key" => "asdf"+ ]);}}diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.phpindex 2d14bd1992..28f4e42fa6 100644--- a/database/seeders/ServerSeeder.php+++ b/database/seeders/ServerSeeder.php@@ -18,7 +18,7 @@ class ServerSeeder extends Seeder{$root_team = Team::find(1);$private_key_1 = PrivateKey::find(1);- $server_1 = Server::create([+ Server::create(['id' => 1,'name' => "testing-host",'description' => "This is a test docker container",diff --git a/resources/views/home.blade.php b/resources/views/home.blade.phpindex 78f3675fd7..031c6a8ce0 100644--- a/resources/views/home.blade.php+++ b/resources/views/home.blade.php@@ -15,6 +15,7 @@<h3>{{ $application->name }}</h3><p>Application: {{ $application }}</p><p>Destination Class: {{ $application->destination->getMorphClass() }}</p>+ <p>Source Class: {{ $application->source->getMorphClass() }}</p>@empty<li>No application found</li>@endforelse