WIP
This commit is contained in:
parent
1c87146a50
commit
653efb6983
19
app/Http/Livewire/TemporaryCheckStatus.php
Normal file
19
app/Http/Livewire/TemporaryCheckStatus.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Application;
|
||||
use Livewire\Component;
|
||||
|
||||
class TemporaryCheckStatus extends Component
|
||||
{
|
||||
public $application_id;
|
||||
|
||||
public function checkStatus() {
|
||||
dd(Application::find(1)->environments);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.temporary-check-status');
|
||||
}
|
||||
}
|
@ -8,4 +8,8 @@ public function environments()
|
||||
{
|
||||
return $this->morphToMany(Environment::class, 'environmentable');
|
||||
}
|
||||
public function destination()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
11
app/Models/StandaloneDocker.php
Normal file
11
app/Models/StandaloneDocker.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class StandaloneDocker extends BaseModel
|
||||
{
|
||||
public function applications()
|
||||
{
|
||||
return $this->morphMany(Application::class, 'destination');
|
||||
}
|
||||
}
|
11
app/Models/SwarmDocker.php
Normal file
11
app/Models/SwarmDocker.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class SwarmDocker extends BaseModel
|
||||
{
|
||||
public function applications()
|
||||
{
|
||||
return $this->morphMany(Application::class, 'destination');
|
||||
}
|
||||
}
|
@ -13,4 +13,7 @@ class Team extends BaseModel
|
||||
public function projects() {
|
||||
return $this->hasMany(Project::class);
|
||||
}
|
||||
public function servers() {
|
||||
return $this->hasMany(Server::class);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public function up(): void
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->string('name');
|
||||
$table->nullableMorphs('destination');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
};
|
@ -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('swarm_dockers', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
]);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
25
database/seeders/StandaloneDockerSeeder.php
Normal file
25
database/seeders/StandaloneDockerSeeder.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Destination;
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneDocker;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class StandaloneDockerSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$server_1 = Server::find(1);
|
||||
StandaloneDocker::create([
|
||||
'id' => 1,
|
||||
'network' => 'coolify',
|
||||
'server_id' => $server_1->id,
|
||||
]);
|
||||
}
|
||||
}
|
26
database/seeders/SwarmDockerSeeder.php
Normal file
26
database/seeders/SwarmDockerSeeder.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Destination;
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\SwarmDocker;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SwarmDockerSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$server_1 = Server::find(1);
|
||||
SwarmDocker::create([
|
||||
'id' => 1,
|
||||
'network' => 'coolify-swarms',
|
||||
'server_id' => $server_1->id,
|
||||
]);
|
||||
}
|
||||
}
|
@ -11,14 +11,23 @@
|
||||
<h2>Environments</h2>
|
||||
@forelse ($project->environments as $environment)
|
||||
<p>Environment Name: {{ $environment->name }}</p>
|
||||
<p>Applications: {{ $environment->applications }}</p>
|
||||
<p>Databases: {{ $environment->databases }}</p>
|
||||
@empty
|
||||
<p>No environments found</p>
|
||||
@endforelse
|
||||
</li>
|
||||
@forelse ($environment->applications as $application)
|
||||
<p>Application: {{ $application }}</p>
|
||||
<livewire:temporary-check-status :application_id="$application->id" />
|
||||
@empty
|
||||
<li>No application found</li>
|
||||
@endforelse
|
||||
@forelse ($environment->databases as $database)
|
||||
<p>Database: {{ $database }}</p>
|
||||
@empty
|
||||
<li>No projects found</li>
|
||||
<li>No database found</li>
|
||||
@endforelse
|
||||
@empty
|
||||
<p>No environments found</p>
|
||||
@endforelse
|
||||
</li>
|
||||
@empty
|
||||
<li>No projects found</li>
|
||||
@endforelse
|
||||
</ul>
|
||||
</x-layout>
|
||||
|
@ -0,0 +1,3 @@
|
||||
<div>
|
||||
<button wire:click='checkStatus'>Check Status</button>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user