fix: proxy configuration + starter
This commit is contained in:
@@ -22,6 +22,7 @@ class StartProxy
|
||||
if (!$configuration) {
|
||||
throw new \Exception("Configuration is not synced");
|
||||
}
|
||||
SaveConfiguration::run($server, $configuration);
|
||||
$docker_compose_yml_base64 = base64_encode($configuration);
|
||||
$server->proxy->last_applied_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
|
||||
$server->save();
|
||||
@@ -50,12 +51,15 @@ class StartProxy
|
||||
"echo '####### Proxy installed successfully.'"
|
||||
]);
|
||||
$commands = $commands->merge(connectProxyToNetworks($server));
|
||||
if (!$async) {
|
||||
instant_remote_process($commands, $server);
|
||||
return 'OK';
|
||||
} else {
|
||||
if ($async) {
|
||||
$activity = remote_process($commands, $server);
|
||||
return $activity;
|
||||
} else {
|
||||
instant_remote_process($commands, $server);
|
||||
$server->proxy->set('status', 'running');
|
||||
$server->proxy->set('type', $proxyType);
|
||||
$server->save();
|
||||
return 'OK';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ class Proxy extends Component
|
||||
|
||||
public function select_proxy($proxy_type)
|
||||
{
|
||||
$this->server->proxy->type = $proxy_type;
|
||||
$this->server->proxy->status = 'exited';
|
||||
$this->server->proxy->set('status', 'exited');
|
||||
$this->server->proxy->set('type', $proxy_type);
|
||||
$this->server->save();
|
||||
$this->selectedProxy = $this->server->proxy->type;
|
||||
$this->emit('proxyStatusUpdated');
|
||||
|
||||
@@ -11,6 +11,8 @@ class Modal extends Component
|
||||
|
||||
public function proxyStatusUpdated()
|
||||
{
|
||||
$this->server->proxy->set('status', 'running');
|
||||
$this->server->save();
|
||||
$this->emit('proxyStatusUpdated');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +77,13 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
||||
$services = $this->server->services();
|
||||
$previews = $this->server->previews();
|
||||
|
||||
$this->server->proxyType();
|
||||
/// Check if proxy is running
|
||||
$foundProxyContainer = $containers->filter(function ($value, $key) {
|
||||
return data_get($value, 'Name') === '/coolify-proxy';
|
||||
})->first();
|
||||
if (!$foundProxyContainer) {
|
||||
ray('Proxy not found, starting it...');
|
||||
if ($this->server->isProxyShouldRun()) {
|
||||
StartProxy::run($this->server, false);
|
||||
$this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server));
|
||||
@@ -99,7 +101,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
||||
|
||||
foreach ($containers as $container) {
|
||||
$containerStatus = data_get($container, 'State.Status');
|
||||
$containerHealth = data_get($container, 'State.Health.Status','unhealthy');
|
||||
$containerHealth = data_get($container, 'State.Health.Status', 'unhealthy');
|
||||
$containerStatus = "$containerStatus ($containerHealth)";
|
||||
$labels = data_get($container, 'Config.Labels');
|
||||
$labels = Arr::undot(format_docker_labels_to_json($labels));
|
||||
|
||||
@@ -78,7 +78,8 @@ class Server extends BaseModel
|
||||
return $this->hasOne(ServerSetting::class);
|
||||
}
|
||||
|
||||
public function proxyType() {
|
||||
public function proxyType()
|
||||
{
|
||||
$type = $this->proxy->get('type');
|
||||
if (is_null($type)) {
|
||||
$this->proxy->type = ProxyTypes::TRAEFIK_V2->value;
|
||||
@@ -115,11 +116,13 @@ class Server extends BaseModel
|
||||
return $standaloneDocker->applications;
|
||||
})->flatten();
|
||||
}
|
||||
public function services() {
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
|
||||
public function previews() {
|
||||
public function previews()
|
||||
{
|
||||
return $this->destinations()->map(function ($standaloneDocker) {
|
||||
return $standaloneDocker->applications->map(function ($application) {
|
||||
return $application->previews;
|
||||
@@ -161,6 +164,9 @@ class Server extends BaseModel
|
||||
public function isProxyShouldRun()
|
||||
{
|
||||
$shouldRun = false;
|
||||
if ($this->proxyType() === ProxyTypes::NONE->value) {
|
||||
return false;
|
||||
}
|
||||
foreach ($this->applications() as $application) {
|
||||
if (data_get($application, 'fqdn')) {
|
||||
$shouldRun = true;
|
||||
@@ -175,7 +181,8 @@ class Server extends BaseModel
|
||||
}
|
||||
return $shouldRun;
|
||||
}
|
||||
public function isFunctional() {
|
||||
public function isFunctional()
|
||||
{
|
||||
return $this->settings->is_reachable && $this->settings->is_usable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,17 +405,16 @@ class Service extends BaseModel
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->server->proxyType() === ProxyTypes::TRAEFIK_V2->value) {
|
||||
$labels = collect(data_get($service, 'labels', []));
|
||||
$labels = collect([]);
|
||||
$labels = $labels->merge(defaultLabels($this->id, $container_name, type: 'service'));
|
||||
if (!$isDatabase) {
|
||||
if ($fqdns) {
|
||||
$labels = $labels->merge(fqdnLabelsForTraefik($fqdns, $container_name, true));
|
||||
}
|
||||
// Add labels to the service
|
||||
$labels = collect(data_get($service, 'labels', []));
|
||||
$labels = collect([]);
|
||||
$labels = $labels->merge(defaultLabels($this->id, $container_name, type: 'service'));
|
||||
if (!$isDatabase) {
|
||||
if ($fqdns) {
|
||||
$labels = $labels->merge(fqdnLabelsForTraefik($fqdns, $container_name, true));
|
||||
}
|
||||
data_set($service, 'labels', $labels->toArray());
|
||||
}
|
||||
data_set($service, 'labels', $labels->toArray());
|
||||
data_forget($service, 'is_database');
|
||||
data_set($service, 'restart', RESTART_MODE);
|
||||
data_set($service, 'container_name', $container_name);
|
||||
|
||||
Reference in New Issue
Block a user