mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 16:14:22 +02:00
wip
This commit is contained in:
commit
f50e850774
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,6 +21,7 @@ yarn-error.log
|
|||||||
/.bash_history
|
/.bash_history
|
||||||
/_volumes
|
/_volumes
|
||||||
|
|
||||||
|
# Temp while developing Proxy deployment
|
||||||
resources/recipes
|
resources/recipes
|
||||||
|
|
||||||
.lesshst
|
.lesshst
|
||||||
|
13
app/Data/ServerMetadata.php
Normal file
13
app/Data/ServerMetadata.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Data;
|
||||||
|
|
||||||
|
use App\Enums\ProxyTypes;
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
|
||||||
|
class ServerMetadata extends Data
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public ?ProxyTypes $proxy,
|
||||||
|
) {}
|
||||||
|
}
|
10
app/Enums/ProxyTypes.php
Normal file
10
app/Enums/ProxyTypes.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum ProxyTypes: string
|
||||||
|
{
|
||||||
|
case TRAEFIK_V2 = 'TRAEFIK_V2';
|
||||||
|
case NGINX = 'NGINX';
|
||||||
|
case CADDY = 'CADDY';
|
||||||
|
}
|
@ -93,6 +93,7 @@ public function application_deployment()
|
|||||||
if (!$application) {
|
if (!$application) {
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
$activity = Activity::query()
|
$activity = Activity::query()
|
||||||
->where('properties->type', '=', 'deployment')
|
->where('properties->type', '=', 'deployment')
|
||||||
->where('properties->uuid', '=', $deployment_uuid)
|
->where('properties->uuid', '=', $deployment_uuid)
|
||||||
|
16
app/Http/Controllers/ServerController.php
Normal file
16
app/Http/Controllers/ServerController.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ServerController extends Controller
|
||||||
|
{
|
||||||
|
public function show(Server $server)
|
||||||
|
{
|
||||||
|
return view('server.show', [
|
||||||
|
'server' => $server,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
44
app/Http/Livewire/ActivityMonitor.php
Normal file
44
app/Http/Livewire/ActivityMonitor.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
|
class ActivityMonitor extends Component
|
||||||
|
{
|
||||||
|
public $activityId;
|
||||||
|
public $isPollingActive = false;
|
||||||
|
|
||||||
|
protected $activity;
|
||||||
|
protected $listeners = ['newMonitorActivity'];
|
||||||
|
|
||||||
|
public function hydrateActivity()
|
||||||
|
{
|
||||||
|
$this->activity = Activity::query()
|
||||||
|
->find($this->activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newMonitorActivity($activityId)
|
||||||
|
{
|
||||||
|
$this->activityId = $activityId;
|
||||||
|
|
||||||
|
$this->hydrateActivity();
|
||||||
|
|
||||||
|
$this->isPollingActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function polling()
|
||||||
|
{
|
||||||
|
$this->hydrateActivity();
|
||||||
|
|
||||||
|
if (data_get($this->activity, 'properties.exitCode') !== null) {
|
||||||
|
$this->isPollingActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.activity-monitor');
|
||||||
|
}
|
||||||
|
}
|
30
app/Http/Livewire/Server/Proxy.php
Normal file
30
app/Http/Livewire/Server/Proxy.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Proxy extends Component
|
||||||
|
{
|
||||||
|
public Server $server;
|
||||||
|
|
||||||
|
protected string $selectedProxy = '';
|
||||||
|
|
||||||
|
public function mount(Server $server)
|
||||||
|
{
|
||||||
|
$this->server = $server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runInstallProxy()
|
||||||
|
{
|
||||||
|
$activity = remoteProcess(['ls -alh'], $this->server);
|
||||||
|
|
||||||
|
$this->emit('newMonitorActivity', $activity->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.server.proxy');
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
|
||||||
|
|
||||||
class Server extends BaseModel
|
class Server extends BaseModel
|
||||||
{
|
{
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
@ -28,10 +31,18 @@ public function swarmDockers()
|
|||||||
{
|
{
|
||||||
return $this->hasMany(SwarmDocker::class);
|
return $this->hasMany(SwarmDocker::class);
|
||||||
}
|
}
|
||||||
|
public $casts = [
|
||||||
|
'extra_attributes' => SchemalessAttributes::class,
|
||||||
|
];
|
||||||
|
public function scopeWithExtraAttributes(): Builder
|
||||||
|
{
|
||||||
|
return $this->extra_attributes->modelScope();
|
||||||
|
}
|
||||||
public function privateKey()
|
public function privateKey()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(PrivateKey::class);
|
return $this->belongsTo(PrivateKey::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settings()
|
public function settings()
|
||||||
{
|
{
|
||||||
return $this->hasOne(ServerSetting::class);
|
return $this->hasOne(ServerSetting::class);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
|
"doctrine/dbal": "^3.6",
|
||||||
"guzzlehttp/guzzle": "^7.5.0",
|
"guzzlehttp/guzzle": "^7.5.0",
|
||||||
"laravel/fortify": "^v1.16.0",
|
"laravel/fortify": "^v1.16.0",
|
||||||
"laravel/framework": "^v10.7.1",
|
"laravel/framework": "^v10.7.1",
|
||||||
@ -18,6 +19,7 @@
|
|||||||
"spatie/laravel-data": "^3.4.3",
|
"spatie/laravel-data": "^3.4.3",
|
||||||
"spatie/laravel-ray": "^1.32.4",
|
"spatie/laravel-ray": "^1.32.4",
|
||||||
"spatie/url": "^2.2",
|
"spatie/url": "^2.2",
|
||||||
|
"spatie/laravel-schemaless-attributes": "^2.4",
|
||||||
"symfony/yaml": "^6.2",
|
"symfony/yaml": "^6.2",
|
||||||
"visus/cuid2": "^2.0.0"
|
"visus/cuid2": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
655
composer.lock
generated
655
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@ public function up(): void
|
|||||||
$table->string('user')->default('root');
|
$table->string('user')->default('root');
|
||||||
$table->foreignId('team_id');
|
$table->foreignId('team_id');
|
||||||
$table->foreignId('private_key_id');
|
$table->foreignId('private_key_id');
|
||||||
|
$table->schemalessAttributes('extra_attributes');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Data\ServerMetadata;
|
||||||
|
use App\Enums\ProxyTypes;
|
||||||
use App\Models\PrivateKey;
|
use App\Models\PrivateKey;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Team;
|
use App\Models\Team;
|
||||||
@ -16,12 +18,16 @@ public function run(): void
|
|||||||
{
|
{
|
||||||
$root_team = Team::find(0);
|
$root_team = Team::find(0);
|
||||||
$private_key_1 = PrivateKey::find(1);
|
$private_key_1 = PrivateKey::find(1);
|
||||||
|
|
||||||
Server::create([
|
Server::create([
|
||||||
'name' => "testing-local-docker-container",
|
'name' => "testing-local-docker-container",
|
||||||
'description' => "This is a test docker container",
|
'description' => "This is a test docker container",
|
||||||
'ip' => "coolify-testing-host",
|
'ip' => "coolify-testing-host",
|
||||||
'team_id' => $root_team->id,
|
'team_id' => $root_team->id,
|
||||||
'private_key_id' => $private_key_1->id,
|
'private_key_id' => $private_key_1->id,
|
||||||
|
'extra_attributes' => ServerMetadata::from([
|
||||||
|
'proxy' => ProxyTypes::TRAEFIK_V2->value
|
||||||
|
]),
|
||||||
]);
|
]);
|
||||||
Server::create([
|
Server::create([
|
||||||
'name' => "testing-local-docker-container-2",
|
'name' => "testing-local-docker-container-2",
|
||||||
@ -29,6 +35,9 @@ public function run(): void
|
|||||||
'ip' => "coolify-testing-host-2",
|
'ip' => "coolify-testing-host-2",
|
||||||
'team_id' => $root_team->id,
|
'team_id' => $root_team->id,
|
||||||
'private_key_id' => $private_key_1->id,
|
'private_key_id' => $private_key_1->id,
|
||||||
|
'extra_attributes' => ServerMetadata::from([
|
||||||
|
//
|
||||||
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
resources/views/livewire/activity-monitor.blade.php
Normal file
17
resources/views/livewire/activity-monitor.blade.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<div class="mt-8">
|
||||||
|
@isset($this->activity)
|
||||||
|
<span>Activity: {{ $this->activity?->id }}</span>
|
||||||
|
<span>Status: {{ $this->activity?->properties->get('status') }}</span>
|
||||||
|
<pre
|
||||||
|
class="h-[400px] flex flex-col-reverse w-full bg-[#cbcbcb] overflow-y-scroll"
|
||||||
|
@if($isPollingActive)
|
||||||
|
wire:poll.750ms="polling"
|
||||||
|
@endif
|
||||||
|
>{{
|
||||||
|
\App\Actions\CoolifyTask\RunRemoteProcess::decodeOutput($this->activity)
|
||||||
|
}}</pre>
|
||||||
|
@else
|
||||||
|
Not monitoring any activity.
|
||||||
|
@endisset
|
||||||
|
|
||||||
|
</div>
|
30
resources/views/livewire/server/proxy.blade.php
Normal file
30
resources/views/livewire/server/proxy.blade.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<div>
|
||||||
|
<h2> Proxy </h2>
|
||||||
|
|
||||||
|
@if($this->server->extra_attributes->proxy)
|
||||||
|
<div class="mt-12">
|
||||||
|
<div>
|
||||||
|
Proxy type: {{ $this->server->extra_attributes->proxy }}
|
||||||
|
</div>
|
||||||
|
<div class="mt-12"> Features in W11.</div>
|
||||||
|
<ul>
|
||||||
|
<li>Edit config file</li>
|
||||||
|
<li>Enable dashboard (blocking port by firewall)</li>
|
||||||
|
<li>Dashboard access - login/password</li>
|
||||||
|
<li>Setup host for Traefik Dashboard</li>
|
||||||
|
<li>Visit (nav to traefik dashboard)</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
No proxy installed.
|
||||||
|
<select wire:model="selectedProxy">
|
||||||
|
<option value="{{ \App\Enums\ProxyTypes::TRAEFIK_V2 }}">
|
||||||
|
{{ \App\Enums\ProxyTypes::TRAEFIK_V2 }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<button wire:click="runInstallProxy">Install Proxy</button>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<livewire:activity-monitor />
|
||||||
|
|
||||||
|
</div>
|
@ -7,4 +7,7 @@
|
|||||||
<p>Network: {{ data_get($docker, 'network') }}</p>
|
<p>Network: {{ data_get($docker, 'network') }}</p>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
<h1> {{ $server->name }}</h1>
|
||||||
|
|
||||||
|
<livewire:server.proxy :server="$server"/>
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
use App\Models\InstanceSettings;
|
use App\Models\InstanceSettings;
|
||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
use App\Models\SwarmDocker;
|
use App\Models\SwarmDocker;
|
||||||
|
use App\Http\Controllers\ServerController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -34,6 +35,15 @@
|
|||||||
'destinations' => $destinations->sortBy('name'),
|
'destinations' => $destinations->sortBy('name'),
|
||||||
]);
|
]);
|
||||||
})->name('dashboard');
|
})->name('dashboard');
|
||||||
|
Route::get('/project/{project_uuid}', [ProjectController::class, 'environments'])->name('project.environments');
|
||||||
|
|
||||||
|
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
|
||||||
|
|
||||||
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ProjectController::class, 'application'])->name('project.application');
|
||||||
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', [ProjectController::class, 'deployment'])->name('project.deployment');
|
||||||
|
|
||||||
|
Route::get('/server/{server:uuid}', [ServerController::class, 'show'])->name('server.show');
|
||||||
|
|
||||||
|
|
||||||
Route::get('/profile', function () {
|
Route::get('/profile', function () {
|
||||||
return view('profile');
|
return view('profile');
|
||||||
|
Loading…
Reference in New Issue
Block a user