diff --git a/passbook/outposts/controllers/docker.py b/passbook/outposts/controllers/docker.py index 1749cf651..46b1ff4ea 100644 --- a/passbook/outposts/controllers/docker.py +++ b/passbook/outposts/controllers/docker.py @@ -26,6 +26,9 @@ class DockerController(BaseController): super().__init__(outpost) self.client = from_env() + def _get_labels(self) -> Dict[str, str]: + return {} + def _get_env(self) -> Dict[str, str]: return { "PASSBOOK_HOST": self.outpost.config.passbook_host, @@ -61,6 +64,7 @@ class DockerController(BaseController): ports={x: x for _, x in self.deployment_ports.items()}, environment=self._get_env(), network_mode="host" if settings.TEST else "bridge", + labels=self._get_labels(), ), True, ) diff --git a/passbook/providers/proxy/controllers/docker.py b/passbook/providers/proxy/controllers/docker.py index 519ac01c8..d31ef8025 100644 --- a/passbook/providers/proxy/controllers/docker.py +++ b/passbook/providers/proxy/controllers/docker.py @@ -1,6 +1,10 @@ """Proxy Provider Docker Contoller""" +from typing import Dict +from urllib.parse import urlparse + from passbook.outposts.controllers.docker import DockerController from passbook.outposts.models import Outpost +from passbook.providers.proxy.models import ProxyProvider class ProxyDockerController(DockerController): @@ -12,3 +16,14 @@ class ProxyDockerController(DockerController): "http": 4180, "https": 4443, } + + def _get_labels(self) -> Dict[str, str]: + hosts = [] + for proxy_provider in ProxyProvider.objects.filter(outpost__in=[self.outpost]): + proxy_provider: ProxyProvider + external_host_name = urlparse(proxy_provider.external_host) + hosts.append(external_host_name) + return { + "traefik.frontend.rule": f"Host:{','.join(hosts)}", + "traefik.port": "4180", + }