diff --git a/app/Http/Livewire/TemporaryCheckStatus.php b/app/Http/Livewire/TemporaryCheckStatus.php new file mode 100644 index 000000000..18250e7c1 --- /dev/null +++ b/app/Http/Livewire/TemporaryCheckStatus.php @@ -0,0 +1,19 @@ +environments); + } + public function render() + { + return view('livewire.temporary-check-status'); + } +} diff --git a/app/Models/Application.php b/app/Models/Application.php index 0ac9475b8..4cf0556a5 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -8,4 +8,8 @@ public function environments() { return $this->morphToMany(Environment::class, 'environmentable'); } + public function destination() + { + return $this->morphTo(); + } } diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index 2f148b1ce..45f69cb2a 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -4,13 +4,8 @@ class PrivateKey extends BaseModel { - public function private_keyables() - { - return $this->hasMany(PrivateKeyable::class); - } - public function servers() { - return $this->morphedByMany(Server::class, 'private_keyable'); + return $this->hasMany(Server::class); } } diff --git a/app/Models/Server.php b/app/Models/Server.php index a703f8003..2f5e67971 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -4,8 +4,8 @@ class Server extends BaseModel { - public function privateKeys() + public function privateKey() { - return $this->morphToMany(PrivateKey::class, 'private_keyable'); + return $this->belongsTo(PrivateKey::class); } } diff --git a/app/Models/StandaloneDocker.php b/app/Models/StandaloneDocker.php new file mode 100644 index 000000000..5d6f8ef4e --- /dev/null +++ b/app/Models/StandaloneDocker.php @@ -0,0 +1,11 @@ +morphMany(Application::class, 'destination'); + } +} diff --git a/app/Models/SwarmDocker.php b/app/Models/SwarmDocker.php new file mode 100644 index 000000000..6d9a93c40 --- /dev/null +++ b/app/Models/SwarmDocker.php @@ -0,0 +1,11 @@ +morphMany(Application::class, 'destination'); + } +} diff --git a/app/Models/Team.php b/app/Models/Team.php index e4118d860..3b05aa1ee 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -13,4 +13,7 @@ class Team extends BaseModel public function projects() { return $this->hasMany(Project::class); } + public function servers() { + return $this->hasMany(Server::class); + } } diff --git a/database/migrations/2023_03_24_140711_create_servers_table.php b/database/migrations/2023_03_24_140711_create_servers_table.php index 0cbd2419a..ba62f7977 100644 --- a/database/migrations/2023_03_24_140711_create_servers_table.php +++ b/database/migrations/2023_03_24_140711_create_servers_table.php @@ -20,6 +20,7 @@ public function up(): void $table->integer('port')->default(22); $table->string('user')->default('root'); $table->foreignId('team_id'); + $table->foreignId('private_key_id'); $table->timestamps(); }); } diff --git a/database/migrations/2023_03_24_140853_create_private_keys_table.php b/database/migrations/2023_03_24_140853_create_private_keys_table.php index 09c6ab0ee..be0c5211f 100644 --- a/database/migrations/2023_03_24_140853_create_private_keys_table.php +++ b/database/migrations/2023_03_24_140853_create_private_keys_table.php @@ -17,7 +17,6 @@ public function up(): void $table->string('name'); $table->string('description')->nullable(); $table->longText('private_key'); - $table->nullableMorphs('private_keys_morph'); $table->timestamps(); }); } diff --git a/database/migrations/2023_03_27_075445_create_environmentsables_table.php b/database/migrations/2023_03_27_075445_create_environmentables_table.php similarity index 100% rename from database/migrations/2023_03_27_075445_create_environmentsables_table.php rename to database/migrations/2023_03_27_075445_create_environmentables_table.php 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 bdfb38fef..de47e0c0a 100644 --- a/database/migrations/2023_03_27_081716_create_applications_table.php +++ b/database/migrations/2023_03_27_081716_create_applications_table.php @@ -15,6 +15,7 @@ public function up(): void $table->id(); $table->string('uuid')->unique(); $table->string('name'); + $table->nullableMorphs('destination'); $table->timestamps(); }); } diff --git a/database/migrations/2023_03_24_203356_create_private_keyables_table.php b/database/migrations/2023_03_27_085020_create_standalone_dockers_table.php similarity index 59% rename from database/migrations/2023_03_24_203356_create_private_keyables_table.php rename to database/migrations/2023_03_27_085020_create_standalone_dockers_table.php index 7c110413c..814d3eee3 100644 --- a/database/migrations/2023_03_24_203356_create_private_keyables_table.php +++ b/database/migrations/2023_03_27_085020_create_standalone_dockers_table.php @@ -11,11 +11,12 @@ */ public function up(): void { - Schema::create('private_keyables', function (Blueprint $table) { + Schema::create('standalone_dockers', function (Blueprint $table) { $table->id(); - $table->unsignedBigInteger('private_key_id'); - $table->unsignedBigInteger('private_keyable_id'); - $table->string('private_keyable_type'); + $table->string('uuid')->unique(); + $table->string('network'); + + $table->foreignId('server_id'); $table->timestamps(); }); } @@ -25,6 +26,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('private_keyables'); + Schema::dropIfExists('standalone_dockers'); } }; diff --git a/database/migrations/2023_03_27_085022_create_swarm_dockers_table.php b/database/migrations/2023_03_27_085022_create_swarm_dockers_table.php new file mode 100644 index 000000000..1db0188ee --- /dev/null +++ b/database/migrations/2023_03_27_085022_create_swarm_dockers_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('uuid')->unique(); + $table->string('network'); + + $table->foreignId('server_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('swarm_dockers'); + } +}; diff --git a/database/seeders/ApplicationSeeder.php b/database/seeders/ApplicationSeeder.php index f75b017b7..26a10b9dc 100644 --- a/database/seeders/ApplicationSeeder.php +++ b/database/seeders/ApplicationSeeder.php @@ -3,10 +3,13 @@ namespace Database\Seeders; use App\Models\Application; +use App\Models\Destination; use App\Models\Environment; use App\Models\Project; +use App\Models\StandaloneDocker; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\DB; class ApplicationSeeder extends Seeder { @@ -16,9 +19,13 @@ class ApplicationSeeder extends Seeder public function run(): void { $environment_1 = Environment::find(1); + $standalone_docker_1 = StandaloneDocker::find(1); + $application_1 = Application::create([ 'id' => 1, 'name' => 'My first application', + 'destination_id' => $standalone_docker_1->id, + 'destination_type' => StandaloneDocker::class, ]); $environment_1->applications()->attach($application_1); } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 8f9ad67c7..35d8d993f 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Models\StandaloneDocker; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder @@ -12,11 +13,13 @@ public function run(): void $this->call([ UserSeeder::class, TeamSeeder::class, - ServerSeeder::class, PrivateKeySeeder::class, + ServerSeeder::class, ProjectSeeder::class, ProjectSettingSeeder::class, EnvironmentSeeder::class, + StandaloneDockerSeeder::class, + SwarmDockerSeeder::class, ApplicationSeeder::class, DBSeeder::class, ]); diff --git a/database/seeders/PrivateKeySeeder.php b/database/seeders/PrivateKeySeeder.php index d3ffc6574..554d949e7 100644 --- a/database/seeders/PrivateKeySeeder.php +++ b/database/seeders/PrivateKeySeeder.php @@ -14,9 +14,7 @@ class PrivateKeySeeder extends Seeder */ public function run(): void { - $server = Server::find(1); - $server2 = Server::find(2); - $private_key = PrivateKey::create([ + PrivateKey::create([ "name" => "Testing-host", "description" => "This is a test docker container", "private_key" => "-----BEGIN OPENSSH PRIVATE KEY----- @@ -26,9 +24,7 @@ public function run(): void AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== -----END OPENSSH PRIVATE KEY----- -", +" ]); - $server->privateKeys()->attach($private_key); - $server2->privateKeys()->attach($private_key); } } diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.php index 22fb68a03..2d14bd199 100644 --- a/database/seeders/ServerSeeder.php +++ b/database/seeders/ServerSeeder.php @@ -2,10 +2,12 @@ namespace Database\Seeders; +use App\Models\PrivateKey; use App\Models\Server; use App\Models\Team; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\DB; class ServerSeeder extends Seeder { @@ -15,12 +17,14 @@ class ServerSeeder extends Seeder public function run(): void { $root_team = Team::find(1); - Server::create([ + $private_key_1 = PrivateKey::find(1); + $server_1 = Server::create([ 'id' => 1, 'name' => "testing-host", 'description' => "This is a test docker container", 'ip' => "coolify-testing-host", 'team_id' => $root_team->id, + 'private_key_id' => $private_key_1->id, ]); Server::create([ 'id' => 2, @@ -28,6 +32,8 @@ public function run(): void 'description' => "This is a test docker container", 'ip' => "coolify-testing-host-2", 'team_id' => $root_team->id, + 'private_key_id' => $private_key_1->id, ]); + } } diff --git a/database/seeders/StandaloneDockerSeeder.php b/database/seeders/StandaloneDockerSeeder.php new file mode 100644 index 000000000..77583700f --- /dev/null +++ b/database/seeders/StandaloneDockerSeeder.php @@ -0,0 +1,25 @@ + 1, + 'network' => 'coolify', + 'server_id' => $server_1->id, + ]); + } +} diff --git a/database/seeders/SwarmDockerSeeder.php b/database/seeders/SwarmDockerSeeder.php new file mode 100644 index 000000000..3447a830d --- /dev/null +++ b/database/seeders/SwarmDockerSeeder.php @@ -0,0 +1,26 @@ + 1, + 'network' => 'coolify-swarms', + 'server_id' => $server_1->id, + ]); + } +} diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 13d214e82..5950aa5fd 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -11,14 +11,23 @@

Environments

@forelse ($project->environments as $environment)

Environment Name: {{ $environment->name }}

-

Applications: {{ $environment->applications }}

-

Databases: {{ $environment->databases }}

- @empty -

No environments found

- @endforelse - + @forelse ($environment->applications as $application) +

Application: {{ $application }}

+ + @empty +
  • No application found
  • + @endforelse + @forelse ($environment->databases as $database) +

    Database: {{ $database }}

    @empty -
  • No projects found
  • +
  • No database found
  • + @endforelse + @empty +

    No environments found

    + @endforelse + + @empty +
  • No projects found
  • @endforelse diff --git a/resources/views/livewire/temporary-check-status.blade.php b/resources/views/livewire/temporary-check-status.blade.php new file mode 100644 index 000000000..0a100bab8 --- /dev/null +++ b/resources/views/livewire/temporary-check-status.blade.php @@ -0,0 +1,3 @@ +
    + +