From 404c664500edc7f2ce863fb1b5bea14d4ef5b229 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 9 Jan 2024 12:29:45 +0100 Subject: [PATCH] fix: traefik labels --- bootstrap/helpers/docker.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 21dfe3e3c..59f45358e 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -249,6 +249,10 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_ // Set labels for http (redirect to https) $labels->push("traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)"); $labels->push("traefik.http.routers.{$http_label}.entryPoints=http"); + $labels->push("traefik.http.routers.{$http_label}.service={$http_label}"); + if ($port) { + $labels->push("traefik.http.services.{$http_label}.loadbalancer.server.port=$port"); + } if ($is_force_https_enabled) { $labels->push("traefik.http.routers.{$http_label}.middlewares=redirect-to-https"); } @@ -257,8 +261,8 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_ $labels->push("traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)"); $labels->push("traefik.http.routers.{$http_label}.entryPoints=http"); $labels->push("traefik.http.routers.{$http_label}.middlewares=gzip"); + $labels->push("traefik.http.routers.{$http_label}.service={$http_label}"); if ($port) { - $labels->push("traefik.http.routers.{$http_label}.service={$http_label}"); $labels->push("traefik.http.services.{$http_label}.loadbalancer.server.port=$port"); } if ($path !== '/') { @@ -266,10 +270,9 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_ $labels->push("traefik.http.middlewares.{$http_label}-stripprefix.stripprefix.prefixes={$path}"); } } - } catch(\Throwable $e) { + } catch (\Throwable $e) { continue; } - } return $labels; @@ -278,7 +281,7 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview { $ports = $application->settings->is_static ? [80] : $application->ports_exposes_array; $onlyPort = null; - if (count($ports) === 1) { + if (count($ports) > 0) { $onlyPort = $ports[0]; } $pull_request_id = data_get($preview, 'pull_request_id', 0);