An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
wip: swarm
Andras Bacsaic41ffd6bfbff
diff --git a/app/Actions/Proxy/StartProxy.php b/app/Actions/Proxy/StartProxy.phpindex b90508c5a3..b6f657b351 100644--- a/app/Actions/Proxy/StartProxy.php+++ b/app/Actions/Proxy/StartProxy.php@@ -13,9 +13,7 @@ class StartProxypublic function handle(Server $server, bool $async = true): string|Activity{try {- if ($server->isSwarm()) {- throw new \Exception("Server is part of swarm, not implemented yet.");- }+$proxyType = $server->proxyType();$commands = collect([]);$proxy_path = get_proxy_path();@@ -27,18 +25,29 @@ class StartProxy$docker_compose_yml_base64 = base64_encode($configuration);$server->proxy->last_applied_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;$server->save();- $commands = $commands->merge([- "mkdir -p $proxy_path && cd $proxy_path",- "echo 'Creating required Docker Compose file.'",- "echo 'Pulling docker image.'",- 'docker compose pull',- "echo 'Stopping existing coolify-proxy.'",- "docker compose down -v --remove-orphans > /dev/null 2>&1",- "echo 'Starting coolify-proxy.'",- 'docker compose up -d --remove-orphans',- "echo 'Proxy started successfully.'"- ]);- $commands = $commands->merge(connectProxyToNetworks($server));+ if ($server->isSwarm()) {+ $commands = $commands->merge([+ "mkdir -p $proxy_path && cd $proxy_path",+ "echo 'Creating required Docker Compose file.'",+ "echo 'Starting coolify-proxy.'",+ // "docker stack deploy -c docker-compose.yaml coolify-proxy",+ "echo 'Proxy started successfully.'"+ ]);+ } else {+ $commands = $commands->merge([+ "mkdir -p $proxy_path && cd $proxy_path",+ "echo 'Creating required Docker Compose file.'",+ "echo 'Pulling docker image.'",+ 'docker compose pull',+ "echo 'Stopping existing coolify-proxy.'",+ "docker compose down -v --remove-orphans > /dev/null 2>&1",+ "echo 'Starting coolify-proxy.'",+ 'docker compose up -d --remove-orphans',+ "echo 'Proxy started successfully.'"+ ]);+ $commands = $commands->merge(connectProxyToNetworks($server));+ }+if ($async) {$activity = remote_process($commands, $server);return $activity;diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.phpindex 2f595d1c6a..614988eca0 100644--- a/bootstrap/helpers/proxy.php+++ b/bootstrap/helpers/proxy.php@@ -102,7 +102,6 @@ function generate_default_proxy_configuration(Server $server)"--entrypoints.https.address=:443","--entrypoints.http.http.encodequerysemicolons=true","--entrypoints.https.http.encodequerysemicolons=true",- "--providers.docker=true","--providers.docker.exposedbydefault=false","--providers.file.directory=/traefik/dynamic/","--providers.file.watch=true",@@ -128,6 +127,18 @@ function generate_default_proxy_configuration(Server $server)$config['services']['traefik']['command'][] = "--accesslog.filepath=/traefik/access.log";$config['services']['traefik']['command'][] = "--accesslog.bufferingsize=100";}+ if ($server->isSwarm()) {+ $config['services']['traefik']['command'][] = "--providers.docker.swarmMode=true";+ $config['services']['traefik']['deploy'] = [+ "placement" => [+ "constraints" => [+ "node.role==manager",+ ],+ ],+ ];+ } else {+ $config['services']['traefik']['command'][] = "--providers.docker=true";+ }$config = Yaml::dump($config, 4, 2);SaveConfiguration::run($server, $config);return $config;