From 071cabdc31d715686e0e74eb2132692af3ee3be7 Mon Sep 17 00:00:00 2001 From: Hederson Boechat Date: Thu, 23 Jan 2025 11:57:34 -0300 Subject: [PATCH] fix(proxy) update traefik proxy config for docker swarm --- app/Actions/Proxy/StartProxy.php | 4 ++-- app/Jobs/ApplicationDeploymentJob.php | 2 +- bootstrap/helpers/proxy.php | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Actions/Proxy/StartProxy.php b/app/Actions/Proxy/StartProxy.php index 9bc506d9b..3139f02e2 100644 --- a/app/Actions/Proxy/StartProxy.php +++ b/app/Actions/Proxy/StartProxy.php @@ -28,13 +28,13 @@ class StartProxy $docker_compose_yml_base64 = base64_encode($configuration); $server->proxy->last_applied_settings = str($docker_compose_yml_base64)->pipe('md5')->value(); $server->save(); - if ($server->isSwarm()) { + if ($server->isSwarmManager()) { $commands = $commands->merge([ "mkdir -p $proxy_path/dynamic", "cd $proxy_path", "echo 'Creating required Docker Compose file.'", "echo 'Starting coolify-proxy.'", - 'docker stack deploy -c docker-compose.yml coolify-proxy', + 'docker stack deploy --detach=true -c docker-compose.yml coolify-proxy', "echo 'Successfully started coolify-proxy.'", ]); } else { diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index a6d3bc1a2..65856633a 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1145,7 +1145,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $this->application_deployment_queue->addLogEntry('Rolling update started.'); $this->execute_remote_command( [ - executeInDocker($this->deployment_uuid, "docker stack deploy --with-registry-auth -c {$this->workdir}{$this->docker_compose_location} {$this->application->uuid}"), + executeInDocker($this->deployment_uuid, "docker stack deploy --detach=true --with-registry-auth -c {$this->workdir}{$this->docker_compose_location} {$this->application->uuid}"), ], ); $this->application_deployment_queue->addLogEntry('Rolling update completed.'); diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php index 463e89b6f..6a258d52b 100644 --- a/bootstrap/helpers/proxy.php +++ b/bootstrap/helpers/proxy.php @@ -187,7 +187,6 @@ function generate_default_proxy_configuration(Server $server) '--entryPoints.https.http2.maxConcurrentStreams=50', '--entrypoints.https.http3', '--providers.file.directory=/traefik/dynamic/', - '--providers.docker.exposedbydefault=false', '--providers.file.watch=true', '--certificatesresolvers.letsencrypt.acme.httpchallenge=true', '--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=http', @@ -212,7 +211,8 @@ function generate_default_proxy_configuration(Server $server) data_forget($config, 'services.traefik.restart'); data_forget($config, 'services.traefik.labels'); - $config['services']['traefik']['command'][] = '--providers.docker.swarmMode=true'; + $config['services']['traefik']['command'][] = '--providers.swarm.endpoint=unix:///var/run/docker.sock'; + $config['services']['traefik']['command'][] = '--providers.swarm.exposedbydefault=false'; $config['services']['traefik']['deploy'] = [ 'labels' => $labels, 'placement' => [ @@ -223,6 +223,7 @@ function generate_default_proxy_configuration(Server $server) ]; } else { $config['services']['traefik']['command'][] = '--providers.docker=true'; + $config['services']['traefik']['command'][] = '--providers.docker.exposedbydefault=false'; } } elseif ($proxy_type === 'CADDY') { $config = [