ddragosd commented on a change in pull request #4142: tools/dev - updated 
intellij script to accommodate docker-compose
URL: 
https://github.com/apache/incubator-openwhisk/pull/4142#discussion_r238041114
 
 

 ##########
 File path: 
core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/DockerContainerFactory.scala
 ##########
 @@ -141,3 +141,55 @@ object DockerContainerFactoryProvider extends 
ContainerFactoryProvider {
   }
 
 }
+
+/**
+ * This contains factory provides a Docker for Mac client which exposes action 
container's ports on the host.
+ */
+object DockerForMacContainerFactoryProvider extends ContainerFactoryProvider {
+  override def instance(actorSystem: ActorSystem,
+                        logging: Logging,
+                        config: WhiskConfig,
+                        instanceId: InvokerInstanceId,
+                        parameters: Map[String, Set[String]]): 
ContainerFactory = {
+
+    new DockerContainerFactory(instanceId, parameters)(
+      actorSystem,
+      actorSystem.dispatcher,
+      logging,
+      new DockerForMacClient()(actorSystem.dispatcher)(logging, actorSystem),
+      new RuncClient()(actorSystem.dispatcher)(logging, actorSystem))
+  }
+
+}
+
+class DockerForMacClient(dockerHost: Option[String] = None)(executionContext: 
ExecutionContext)(implicit log: Logging,
+                                                                               
                 as: ActorSystem)
+    extends DockerClientWithFileAccess(dockerHost)(executionContext)
+    with DockerApiWithFileAccess {
+
+  implicit private val ec: ExecutionContext = executionContext
+
+  override def run(image: String, args: Seq[String] = Seq.empty[String])(
+    implicit transid: TransactionId): Future[ContainerId] = {
+    // b/c docker for mac doesn't have a routing to the action containers
+    // the port 8080 is exposed on the host on a random port number
+    val extraArgs: Seq[String] = Seq("-p", "0:8080") ++ args
+    super.run(image, extraArgs)
+  }
+  // See extended trait for description
+  override def inspectIPAddress(id: ContainerId, network: String)(
+    implicit transid: TransactionId): Future[ContainerAddress] = {
+    super
+      .runCmd(
+        Seq(
+          "inspect",
+          "--format",
+          s"""{{(index (index .NetworkSettings.Ports "8080/tcp") 
0).HostPort}}""",
+          id.asString),
+        Duration(10000, "millis"))
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to