This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First stage, SBT, identifer named `builder` | |
FROM mozilla/sbt:8u232_1.3.13 AS builder | |
# ADD all source | |
ADD . / | |
# Run SBT assembly, if tests fail, the docker image will not build | |
RUN sbt assembly | |
# Second stage, OpenJDK for JVM runtime | |
FROM adoptopenjdk/openjdk11:jdk-11.0.7_10-debian-slim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################# | |
# Assemble uber-jar using Mozilla's SBT Image | |
############################################################################# | |
FROM mozilla/sbt:8u232_1.3.8 as builder | |
ENV SBT_OPTS="-Xss2M -Xms512M -Xmx2G" | |
COPY . / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libraryDependencies ++= Seq( | |
"org.scalatest" %% "scalatest" % "3.0.8" % Test, | |
"com.dimafeng" %% "testcontainers-scala-scalatest" % "0.37.0" % Test | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestContainersExample2 extends TestContainersApiTestHarness { | |
override def beforeAll(): Unit = { | |
super.beforeAll() | |
importFile("/etc/data1.txt") | |
} | |
"TestContainersEx2" should "return NONE when the data does not exist" in { | |
val result = getDataId("keyThatIsBad") | |
result shouldBe Right(None) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait TestContainersApiTestHarness extends FlatSpec with Matchers with BeforeAndAfterAll { | |
private val REDIS_PORT = 6379 | |
private val container = GenericContainer("redis:5.0.8-alpine", | |
exposedPorts = Seq(REDIS_PORT), | |
waitStrategy = Wait.forListeningPort() | |
) | |
container.start() | |
private val mappedRedisExternalPort = container.mappedPort(REDIS_PORT) | |
private val redisClient = new RedisClient("localhost", mappedRedisExternalPort) | |
private val dao = new RedisTestContainersDao(redisClient) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestContainersExample1 extends FlatSpec with Matchers with BeforeAndAfterAll { | |
private val container = GenericContainer("redis:5.0.8-alpine", | |
waitStrategy = Wait.forListeningPort() | |
) | |
container.start() | |
override def afterAll(): Unit = { | |
super.afterAll() | |
container.stop() | |
} |