diff --git a/app/Actions/Proxy/CheckProxySettingsInSync.php b/app/Actions/Proxy/CheckProxySettingsInSync.php
index 874dd830e..ae0142fec 100644
--- a/app/Actions/Proxy/CheckProxySettingsInSync.php
+++ b/app/Actions/Proxy/CheckProxySettingsInSync.php
@@ -20,7 +20,7 @@ public function __invoke(Server $server, bool $reset = false)
$final_output = Str::of($output)->trim()->value;
}
$docker_compose_yml_base64 = base64_encode($final_output);
- $server->extra_attributes->proxy_last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
+ $server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
$server->save();
if (is_null($output) || $reset) {
instant_remote_process([
diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.php
index 21c19d3a6..c967a4687 100644
--- a/app/Actions/Proxy/InstallProxy.php
+++ b/app/Actions/Proxy/InstallProxy.php
@@ -12,9 +12,9 @@ class InstallProxy
{
public function __invoke(Server $server): Activity
{
- if (is_null(data_get($server, 'extra_attributes.proxy_type'))) {
- $server->extra_attributes->proxy_type = ProxyTypes::TRAEFIK_V2->value;
- $server->extra_attributes->proxy_status = ProxyStatus::EXITED->value;
+ if (is_null(data_get($server, 'proxy.type'))) {
+ $server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
+ $server->proxy->status = ProxyStatus::EXITED->value;
$server->save();
}
$proxy_path = config('coolify.proxy_config_path');
@@ -38,7 +38,7 @@ public function __invoke(Server $server): Activity
$configuration = Str::of($configuration)->trim()->value;
}
$docker_compose_yml_base64 = base64_encode($configuration);
- $server->extra_attributes->proxy_last_applied_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
+ $server->proxy->last_applied_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
$server->save();
$activity = remote_process([
"echo 'Creating required Docker networks...'",
diff --git a/app/Data/ServerMetadata.php b/app/Data/ServerMetadata.php
index 06f11f206..b96efa622 100644
--- a/app/Data/ServerMetadata.php
+++ b/app/Data/ServerMetadata.php
@@ -9,8 +9,8 @@
class ServerMetadata extends Data
{
public function __construct(
- public ?ProxyTypes $proxy_type,
- public ?ProxyStatus $proxy_status
+ public ?ProxyTypes $type,
+ public ?ProxyStatus $status
) {
}
}
diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php
index 4a5eb466d..2403fab33 100644
--- a/app/Http/Livewire/Server/Proxy.php
+++ b/app/Http/Livewire/Server/Proxy.php
@@ -23,14 +23,14 @@ public function serverValidated()
}
public function switchProxy()
{
- $this->server->extra_attributes->proxy_type = null;
+ $this->server->proxy->type = null;
$this->server->save();
}
public function installProxy()
{
if (
- $this->server->extra_attributes->proxy_last_applied_settings &&
- $this->server->extra_attributes->proxy_last_saved_settings !== $this->server->extra_attributes->proxy_last_applied_settings
+ $this->server->proxy->last_applied_settings &&
+ $this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings
) {
$this->saveConfiguration($this->server);
}
@@ -40,8 +40,8 @@ public function installProxy()
public function setProxy(string $proxy_type)
{
- $this->server->extra_attributes->proxy_type = $proxy_type;
- $this->server->extra_attributes->proxy_status = 'exited';
+ $this->server->proxy->type = $proxy_type;
+ $this->server->proxy->status = 'exited';
$this->server->save();
}
public function stopProxy()
@@ -49,7 +49,7 @@ public function stopProxy()
instant_remote_process([
"docker rm -f coolify-proxy",
], $this->server);
- $this->server->extra_attributes->proxy_status = 'exited';
+ $this->server->proxy->status = 'exited';
$this->server->save();
}
public function saveConfiguration(Server $server)
@@ -58,7 +58,7 @@ public function saveConfiguration(Server $server)
$proxy_path = config('coolify.proxy_config_path');
$this->proxy_settings = Str::of($this->proxy_settings)->trim()->value;
$docker_compose_yml_base64 = base64_encode($this->proxy_settings);
- $server->extra_attributes->proxy_last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
+ $server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
$server->save();
instant_remote_process([
"echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
diff --git a/app/Http/Livewire/Server/Proxy/Deploy.php b/app/Http/Livewire/Server/Proxy/Deploy.php
index 58f5e5851..aa12886f2 100644
--- a/app/Http/Livewire/Server/Proxy/Deploy.php
+++ b/app/Http/Livewire/Server/Proxy/Deploy.php
@@ -19,8 +19,8 @@ public function proxyStatusUpdated()
public function deploy()
{
if (
- $this->server->extra_attributes->proxy_last_applied_settings &&
- $this->server->extra_attributes->proxy_last_saved_settings !== $this->server->extra_attributes->proxy_last_applied_settings
+ $this->server->proxy->last_applied_settings &&
+ $this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings
) {
$this->saveConfiguration($this->server);
}
@@ -32,7 +32,7 @@ public function stop()
instant_remote_process([
"docker rm -f coolify-proxy",
], $this->server);
- $this->server->extra_attributes->proxy_status = 'exited';
+ $this->server->proxy->status = 'exited';
$this->server->save();
$this->emit('proxyStatusUpdated');
}
diff --git a/app/Jobs/InstanceProxyCheckJob.php b/app/Jobs/InstanceProxyCheckJob.php
index d2cf894f7..4387cd318 100755
--- a/app/Jobs/InstanceProxyCheckJob.php
+++ b/app/Jobs/InstanceProxyCheckJob.php
@@ -29,7 +29,7 @@ public function handle()
{
try {
$container_name = 'coolify-proxy';
- $servers = Server::whereRelation('settings', 'is_reachable', true)->where('extra_attributes->proxy_type', ProxyTypes::TRAEFIK_V2)->get();
+ $servers = Server::whereRelation('settings', 'is_reachable', true)->where('proxy->type', ProxyTypes::TRAEFIK_V2)->get();
foreach ($servers as $server) {
$status = get_container_status(server: $server, container_id: $container_name);
diff --git a/app/Jobs/ProxyContainerStatusJob.php b/app/Jobs/ProxyContainerStatusJob.php
index 9c3dcbfdc..7c4b15ca5 100644
--- a/app/Jobs/ProxyContainerStatusJob.php
+++ b/app/Jobs/ProxyContainerStatusJob.php
@@ -3,8 +3,6 @@
namespace App\Jobs;
use App\Enums\ProxyTypes;
-use App\Models\Application;
-use App\Models\ApplicationPreview;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
@@ -12,8 +10,8 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
-use Str;
use Illuminate\Queue\Middleware\WithoutOverlapping;
+use Illuminate\Support\Str;
class ProxyContainerStatusJob implements ShouldQueue, ShouldBeUnique
{
@@ -39,13 +37,13 @@ public function handle(): void
try {
$container = get_container_status(server: $this->server, all_data: true, container_id: 'coolify-proxy', throwError: true);
$status = $container['State']['Status'];
- if ($this->server->extra_attributes->proxy_status !== $status) {
- $this->server->extra_attributes->proxy_status = $status;
- if ($this->server->extra_attributes->proxy_status === 'running') {
+ if ($this->server->proxy->status !== $status) {
+ $this->server->proxy->status = $status;
+ if ($this->server->proxy->status === 'running') {
$traefik = $container['Config']['Labels']['org.opencontainers.image.title'];
$version = $container['Config']['Labels']['org.opencontainers.image.version'];
if (isset($version) && isset($traefik) && $traefik === 'Traefik' && Str::of($version)->startsWith('v2')) {
- $this->server->extra_attributes->proxy_type = ProxyTypes::TRAEFIK_V2->value;
+ $this->server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
}
}
$this->server->save();
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 1a1a9704f..5382f6dfd 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -4,9 +4,17 @@
use Illuminate\Database\Eloquent\Builder;
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
+use Spatie\SchemalessAttributes\SchemalessAttributesTrait;
class Server extends BaseModel
{
+ use SchemalessAttributesTrait;
+ protected $schemalessAttributes = [
+ 'proxy',
+ ];
+ public $casts = [
+ 'proxy' => SchemalessAttributes::class,
+ ];
protected static function booted()
{
static::created(function ($server) {
@@ -25,16 +33,14 @@ protected static function booted()
'port',
'team_id',
'private_key_id',
- 'extra_attributes',
+ 'proxy',
];
- public $casts = [
- 'extra_attributes' => SchemalessAttributes::class,
- ];
- public function scopeWithExtraAttributes(): Builder
+
+ public function scopeWithProxy(): Builder
{
- return $this->extra_attributes->modelScope();
+ return $this->proxy->modelScope();
}
public function isEmpty()
{
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 84e2ab6ba..0f3bf7419 100644
--- a/database/migrations/2023_03_24_140711_create_servers_table.php
+++ b/database/migrations/2023_03_24_140711_create_servers_table.php
@@ -21,7 +21,7 @@ public function up(): void
$table->string('user')->default('root');
$table->foreignId('team_id');
$table->foreignId('private_key_id');
- $table->schemalessAttributes('extra_attributes');
+ $table->schemalessAttributes('proxy');
$table->timestamps();
});
}
diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php
index 096e3d12d..de46bf959 100644
--- a/database/seeders/ProductionSeeder.php
+++ b/database/seeders/ProductionSeeder.php
@@ -77,9 +77,9 @@ public function run(): void
'team_id' => 0,
'private_key_id' => 0
];
- $server_details['extra_attributes'] = ServerMetadata::from([
- 'proxy_type' => ProxyTypes::TRAEFIK_V2->value,
- 'proxy_status' => ProxyStatus::EXITED->value
+ $server_details['proxy'] = ServerMetadata::from([
+ 'type' => ProxyTypes::TRAEFIK_V2->value,
+ 'status' => ProxyStatus::EXITED->value
]);
$server = Server::create($server_details);
$server->settings->is_reachable = true;
diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.php
index 2f265d5da..886b1e5b7 100644
--- a/database/seeders/ServerSeeder.php
+++ b/database/seeders/ServerSeeder.php
@@ -28,9 +28,9 @@ public function run(): void
'ip' => "coolify-testing-host",
'team_id' => $root_team->id,
'private_key_id' => $private_key_1->id,
- 'extra_attributes' => ServerMetadata::from([
- 'proxy_type' => ProxyTypes::TRAEFIK_V2->value,
- 'proxy_status' => ProxyStatus::EXITED->value
+ 'proxy' => ServerMetadata::from([
+ 'type' => ProxyTypes::TRAEFIK_V2->value,
+ 'status' => ProxyStatus::EXITED->value
]),
]);
Server::create([
diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php
index 2a8cce4fd..1bbf2fbef 100644
--- a/resources/views/livewire/server/proxy.blade.php
+++ b/resources/views/livewire/server/proxy.blade.php
@@ -2,7 +2,7 @@