Skip to content

Commit 266332e

Browse files
Start multiple docker containers (#4)
* Start multiple docker containers * Remove experimental code * Remove this too * Update README
1 parent 9db1379 commit 266332e

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ starting up dynamodb-local and binding it to port 8000 on the host. When the tes
2828
container will be shutdown.
2929

3030
```
31-
testDockerConfig := Some(DockerConfig("amazon/dynamodb-local", 8000, 8000)),
31+
testDockerConfig := Seq(DockerConfig("amazon/dynamodb-local", 8000, 8000)),
3232
testDockerStart := testDockerStart.dependsOn(Test / compile).value,
3333
Test / test := (Test / test).dependsOn(testDockerStart).value,
3434
Test / testOnly := (Test / testOnly).dependsOn(testDockerStart).evaluated,

src/main/scala/com/lifeway/sbt/testdocker/StartTestDocker.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import scala.util.Try
1212
object StartTestDocker {
1313
private def isHostPortActive(port: Int): Boolean = Try(new Socket("localhost", port).close()).isSuccess
1414
def apply(
15-
dockerConfigOpt: Option[DockerConfig],
15+
dockerConfig: Seq[DockerConfig],
1616
streamz: TaskStreams
1717
): Unit = {
18-
dockerConfigOpt.fold(streamz.log.error("DOCKER WILL NOT BE STARTING. CONFIGURATION NOT PROVIDED")) { config =>
18+
if (dockerConfig.length == 0) streamz.log.error("DOCKER WILL NOT BE STARTING. CONFIGURATION NOT PROVIDED")
19+
dockerConfig.foreach { config =>
1920
val containerImage = config.image
2021
val containerPort = config.containerPort
2122
val hostPort = config.hostPort

src/main/scala/com/lifeway/sbt/testdocker/StopTestDocker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import TestDockerKeys.DockerConfig
77
import scala.sys.process._
88

99
object StopTestDocker {
10-
def apply(dockerConfig: Option[DockerConfig], streamz: TaskStreams): Unit = {
10+
def apply(dockerConfig: Seq[DockerConfig], streamz: TaskStreams): Unit = {
1111
dockerConfig.foreach { config =>
1212
streamz.log.info(s"Stopping test-docker on port ${config.hostPort}")
1313
s"docker stop sbt-testdocker-${config.hostPort}".!

src/main/scala/com/lifeway/sbt/testdocker/TestDockerKeys.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import scala.concurrent.duration._
99

1010
object TestDockerKeys {
1111
case class DockerConfig(image: String, containerPort: Int, hostPort: Int)
12-
lazy val testDockerConfig = settingKey[Option[DockerConfig]]("Container image, container port, and host port to use.")
12+
lazy val testDockerConfig = settingKey[Seq[DockerConfig]]("Container image, container port, and host port to use.")
1313

1414
lazy val testDockerStart = TaskKey[Unit]("start-test-docker")
1515
lazy val testDockerStop = TaskKey[Unit]("stop-test-docker")
1616
lazy val testDockerCleanup = TaskKey[Tests.Cleanup]("test-docker-test-cleanup")
1717

1818
lazy val baseTestDockerSettings = Seq(
19-
testDockerConfig := None,
19+
testDockerConfig := Nil,
2020
testDockerStart := StartTestDocker(
2121
testDockerConfig.value,
2222
streams.value

0 commit comments

Comments
 (0)