-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
56 lines (49 loc) · 2.21 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.io.File
name := "akkadocker"
lazy val commonSettings = Seq(
version := "0.1.SNAPSHOT",
organization := "com.bfg",
scalaVersion := "2.12.1"
)
enablePlugins(DockerComposePlugin)
docker <<= (docker in bfg) map {(image) => image}
//Set the image creation Task to be the one used by sbt-docker
dockerImageCreationTask := docker.value
lazy val bfg = project
.settings(
name := "bfg",
Defaults.itSettings,
commonSettings,
libraryDependencies += "com.typesafe.akka" %% "akka-http" % "10.0.5",
composeFile := s"${baseDirectory.value.absolutePath}/../docker/docker-compose.yml",
dockerImageCreationTask := docker.value,
//To use 'dockerComposeTest' to run tests in the 'IntegrationTest' scope instead of the default 'Test' scope:
// 1) Package the tests that exist in the IntegrationTest scope
testCasesPackageTask := (sbt.Keys.packageBin in IntegrationTest).value,
// 2) Specify the path to the IntegrationTest jar produced in Step 1
testCasesJar := artifactPath.in(IntegrationTest, packageBin).value.getAbsolutePath,
// 3) Include any IntegrationTest scoped resources on the classpath if they are used in the tests
testDependenciesClasspath := {
val fullClasspathCompile = (fullClasspath in Compile).value
val classpathTestManaged = (managedClasspath in IntegrationTest).value
val classpathTestUnmanaged = (unmanagedClasspath in IntegrationTest).value
val testResources = (resources in IntegrationTest).value
(fullClasspathCompile.files ++ classpathTestManaged.files ++ classpathTestUnmanaged.files ++ testResources).map(_.getAbsoluteFile).mkString(File.pathSeparator)
},
dockerfile in docker := {
new Dockerfile {
val dockerAppPath = "/app/"
val mainClassString = (mainClass in Compile).value.get
val classpath = (fullClasspath in Compile).value
from("java")
add(classpath.files, dockerAppPath)
entryPoint("java", "-cp", s"$dockerAppPath:$dockerAppPath/*", s"$mainClassString")
}
},
imageNames in docker := Seq(ImageName(
repository = name.value.toLowerCase,
tag = Some(version.value))
)
)
.configs(IntegrationTest)
.enablePlugins(DockerPlugin, DockerComposePlugin)