feat: add Traefik routing labels for customer apps with exposed ports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-04 21:03:04 +02:00
parent 08b87edd6e
commit 210da55e7a

View File

@@ -126,6 +126,17 @@ public class DeploymentService {
}); });
} }
// Build Traefik labels for inbound routing
var labels = new java.util.HashMap<String, String>();
if (app.getExposedPort() != null) {
labels.put("traefik.enable", "true");
labels.put("traefik.http.routers." + containerName + ".rule",
"Host(`" + app.getSlug() + "." + env.getSlug() + "."
+ tenantSlug + "." + runtimeConfig.getDomain() + "`)");
labels.put("traefik.http.services." + containerName + ".loadbalancer.server.port",
String.valueOf(app.getExposedPort()));
}
var containerId = runtimeOrchestrator.startContainer(new StartContainerRequest( var containerId = runtimeOrchestrator.startContainer(new StartContainerRequest(
deployment.getImageRef(), deployment.getImageRef(),
containerName, containerName,
@@ -141,7 +152,7 @@ public class DeploymentService {
runtimeConfig.parseMemoryLimitBytes(), runtimeConfig.parseMemoryLimitBytes(),
runtimeConfig.getContainerCpuShares(), runtimeConfig.getContainerCpuShares(),
runtimeConfig.getAgentHealthPort(), runtimeConfig.getAgentHealthPort(),
Map.of() labels
)); ));
deployment.setOrchestratorMetadata(Map.of("containerId", containerId)); deployment.setOrchestratorMetadata(Map.of("containerId", containerId));