feat: use configured DOCKER_NETWORK as primary for deployed apps
Instead of hardcoding cameleer-traefik as the primary network for
deployed app containers, use CAMELEER_DOCKER_NETWORK (env var). In
SaaS mode this is the tenant-isolated network (cameleer-tenant-{slug}).
Apps still connect to cameleer-traefik (for routing) and cameleer-env-
{slug} (for intra-environment discovery) as additional networks.
This enables per-tenant network isolation: apps deployed by tenant A
cannot reach apps deployed by tenant B since they share no network.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -107,13 +107,19 @@ public class DeploymentExecutor {
|
||||
|
||||
// === CREATE NETWORKS ===
|
||||
updateStage(deployment.id(), DeployStage.CREATE_NETWORK);
|
||||
// Primary network: use configured CAMELEER_DOCKER_NETWORK (tenant-isolated in SaaS mode)
|
||||
String primaryNetwork = dockerNetwork;
|
||||
String envNet = null;
|
||||
List<String> additionalNets = new ArrayList<>();
|
||||
if (networkManager != null) {
|
||||
primaryNetwork = DockerNetworkManager.TRAEFIK_NETWORK;
|
||||
networkManager.ensureNetwork(primaryNetwork);
|
||||
// Traefik network for routing (apps need to be reachable by Traefik)
|
||||
networkManager.ensureNetwork(DockerNetworkManager.TRAEFIK_NETWORK);
|
||||
additionalNets.add(DockerNetworkManager.TRAEFIK_NETWORK);
|
||||
// Per-environment network for intra-environment service discovery
|
||||
envNet = DockerNetworkManager.envNetworkName(env.slug());
|
||||
networkManager.ensureNetwork(envNet);
|
||||
additionalNets.add(envNet);
|
||||
}
|
||||
|
||||
// === START REPLICAS ===
|
||||
@@ -133,7 +139,7 @@ public class DeploymentExecutor {
|
||||
containerName, baseImage, jarPath,
|
||||
volumeName, jarStoragePath,
|
||||
primaryNetwork,
|
||||
envNet != null ? List.of(envNet) : List.of(),
|
||||
additionalNets,
|
||||
baseEnvVars, labels,
|
||||
config.memoryLimitBytes(), config.memoryReserveBytes(),
|
||||
config.dockerCpuShares(), config.dockerCpuQuota(),
|
||||
@@ -144,9 +150,11 @@ public class DeploymentExecutor {
|
||||
String containerId = orchestrator.startContainer(request);
|
||||
newContainerIds.add(containerId);
|
||||
|
||||
// Connect to environment network after container is started
|
||||
if (networkManager != null && envNet != null) {
|
||||
networkManager.connectContainer(containerId, envNet);
|
||||
// Connect to additional networks after container is started
|
||||
for (String net : additionalNets) {
|
||||
if (networkManager != null) {
|
||||
networkManager.connectContainer(containerId, net);
|
||||
}
|
||||
}
|
||||
|
||||
replicaStates.add(Map.of(
|
||||
|
||||
Reference in New Issue
Block a user