fix(proxy) update traefik proxy config for docker swarm

This commit is contained in:
Hederson Boechat
2025-01-23 11:57:34 -03:00
parent 9a5f1edee7
commit 071cabdc31
3 changed files with 6 additions and 5 deletions

View File

@@ -28,13 +28,13 @@ class StartProxy
$docker_compose_yml_base64 = base64_encode($configuration); $docker_compose_yml_base64 = base64_encode($configuration);
$server->proxy->last_applied_settings = str($docker_compose_yml_base64)->pipe('md5')->value(); $server->proxy->last_applied_settings = str($docker_compose_yml_base64)->pipe('md5')->value();
$server->save(); $server->save();
if ($server->isSwarm()) { if ($server->isSwarmManager()) {
$commands = $commands->merge([ $commands = $commands->merge([
"mkdir -p $proxy_path/dynamic", "mkdir -p $proxy_path/dynamic",
"cd $proxy_path", "cd $proxy_path",
"echo 'Creating required Docker Compose file.'", "echo 'Creating required Docker Compose file.'",
"echo 'Starting coolify-proxy.'", "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.'", "echo 'Successfully started coolify-proxy.'",
]); ]);
} else { } else {

View File

@@ -1145,7 +1145,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$this->application_deployment_queue->addLogEntry('Rolling update started.'); $this->application_deployment_queue->addLogEntry('Rolling update started.');
$this->execute_remote_command( $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.'); $this->application_deployment_queue->addLogEntry('Rolling update completed.');

View File

@@ -187,7 +187,6 @@ function generate_default_proxy_configuration(Server $server)
'--entryPoints.https.http2.maxConcurrentStreams=50', '--entryPoints.https.http2.maxConcurrentStreams=50',
'--entrypoints.https.http3', '--entrypoints.https.http3',
'--providers.file.directory=/traefik/dynamic/', '--providers.file.directory=/traefik/dynamic/',
'--providers.docker.exposedbydefault=false',
'--providers.file.watch=true', '--providers.file.watch=true',
'--certificatesresolvers.letsencrypt.acme.httpchallenge=true', '--certificatesresolvers.letsencrypt.acme.httpchallenge=true',
'--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=http', '--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.restart');
data_forget($config, 'services.traefik.labels'); 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'] = [ $config['services']['traefik']['deploy'] = [
'labels' => $labels, 'labels' => $labels,
'placement' => [ 'placement' => [
@@ -223,6 +223,7 @@ function generate_default_proxy_configuration(Server $server)
]; ];
} else { } else {
$config['services']['traefik']['command'][] = '--providers.docker=true'; $config['services']['traefik']['command'][] = '--providers.docker=true';
$config['services']['traefik']['command'][] = '--providers.docker.exposedbydefault=false';
} }
} elseif ($proxy_type === 'CADDY') { } elseif ($proxy_type === 'CADDY') {
$config = [ $config = [