Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
route by path (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
sekulicd authored Oct 6, 2023
1 parent c0501b9 commit 8ed536c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions app/core/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,10 @@ def get_service_object(
if config.PROXY_ENABLED:
domain = utils.check_dns_exists()
if domain:
service["invokeMethod"] = {
"header": None,
"baseUrl": f"{service['id']}.{domain}",
}
service["baseUrl"] = f"https://{service['id']}.{domain}"
else:
ip = utils.get_deployment_ip()
service["invokeMethod"] = {
"header": f"X-Host-Override:{service['id']}",
"baseUrl": ip,
}
service["baseUrl"] = f"http://{ip}/{service['id']}"
return service


Expand Down Expand Up @@ -214,8 +208,9 @@ def run_container_with_retries(service_object):
else:
labels = {
"traefik.enable": "true",
f"traefik.http.routers.{service_id}.rule": f"HeadersRegexp(`X-Host-Override`,`{service_id}`)"
f" && PathPrefix(`/`)",
f"traefik.http.routers.{service_id}.rule": f"PathPrefix(`/{service_id}`)",
f"traefik.http.middlewares.{service_id}-strip-prefix.stripprefix.prefixes": f"/{service_id}",
f"traefik.http.routers.{service_id}.middlewares": f"{service_id}-strip-prefix",
}

container = client.containers.run(
Expand Down
2 changes: 1 addition & 1 deletion app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ServiceResponse(BaseModel):
envVariables: list[str] = None
execCommands: list[str] = None
promptTemplate: str = None
invokeMethod: dict = None
baseUrl: str = None


class RegistryInput(BaseModel):
Expand Down

0 comments on commit 8ed536c

Please sign in to comment.