@@ -36,27 +36,37 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
36
36
}
37
37
38
38
case create(componentType, instanceId, containerName) =>
39
- val containerConfig = ContainerConfig (Image = DockerImage .getImageName(componentType),
40
- Env = Seq (s " INSTANCE_ID= $instanceId" , s " DELPHI_IR_URI= ${Registry .configuration.uriInLocalNetwork}" ,
41
- s " DELPHI_JWT_SECRET= ${Registry .configuration.jwtSecretKey}" ))
39
+
40
+ val instancePort = componentType match {
41
+ case ComponentType .Crawler => Registry .configuration.defaultCrawlerPort
42
+ case ComponentType .WebApi => Registry .configuration.defaultWebApiPort
43
+ case ComponentType .WebApp => Registry .configuration.defaultWepAppPort
44
+ case t => throw new RuntimeException (s " Invalid component type $t, cannot deploy container. " )
45
+ }
46
+
47
+ val networkConfig = NetworkConfig (Map (Registry .configuration.traefikDockerNetwork -> EmptyEndpointConfig ()))
48
+
49
+ val traefikHostUrl = componentType.toString.toLowerCase + instanceId.toString + " ." + Registry .configuration.traefikBaseHost
50
+
51
+ val containerConfig = ContainerConfig (
52
+ Image = DockerImage .getImageName(componentType),
53
+ Env = Seq (
54
+ s " INSTANCE_ID= $instanceId" ,
55
+ s " DELPHI_IR_URI= ${Registry .configuration.uriInLocalNetwork}" ,
56
+ s " DELPHI_JWT_SECRET= ${Registry .configuration.jwtSecretKey}"
57
+ ),
58
+ Labels = Map (" traefik.frontend.rule" -> s " Host: $traefikHostUrl" ),
59
+ ExposedPorts = Map (s " $instancePort/tcp " -> EmptyExposedPortConfig ()),
60
+ NetworkingConfig = networkConfig
61
+ )
42
62
43
63
val createCommand = Try (Await .result(container.create(containerConfig, containerName), Duration .Inf ))
44
64
createCommand match {
45
65
case Failure (ex) => sender ! Failure (ex)
46
66
case Success (containerResult) =>
47
67
Await .ready(container.start(containerResult.Id ), Duration .Inf )
48
- log.info(s " Docker Instance created and started " )
49
- val containerInfo = Await .result(container.get(containerResult.Id ), Duration .Inf )
50
-
51
- val instancePort = componentType match {
52
- case ComponentType .Crawler => Registry .configuration.defaultCrawlerPort
53
- case ComponentType .WebApi => Registry .configuration.defaultWebApiPort
54
- case ComponentType .WebApp => Registry .configuration.defaultWepAppPort
55
- case t => throw new RuntimeException (s " Invalid component type $t, cannot deploy container. " )
56
- }
57
-
58
- log.info(" ip address is " + containerInfo.IPAddress )
59
- sender ! Success (containerResult.Id , containerInfo.IPAddress , instancePort)
68
+ log.info(s " Docker Instance created and started, host is $traefikHostUrl" )
69
+ sender ! Success (containerResult.Id , traefikHostUrl, instancePort)
60
70
}
61
71
62
72
case stop(containerId) =>
0 commit comments