This repository has been archived by the owner on Feb 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sbt
57 lines (52 loc) · 1.82 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
57
// Enable plugins
enablePlugins(DockerPlugin)
lazy val assemblyFolder = file("assembly")
lazy val ignoreFiles = List("application.conf.sample")
// Runtime
scalaVersion := "2.13.3"
scalacOptions ++= CompilerFlags.all
resolvers += Resolver.sonatypeRepo("releases")
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
// Dependencies
libraryDependencies ++= Dependencies.all
// Projects
lazy val root = (project in file("."))
.settings(
organization := "co.ledger",
name := "ledger-scala-template",
version := "0.0.1-SNAPSHOT",
cleanFiles += assemblyFolder,
test in assembly := {},
assemblyOutputPath in assembly := assemblyFolder / (name.value + "-v" + version.value + ".jar"),
// Remove resources files from the JAR (they will be copied to an external folder)
assemblyMergeStrategy in assembly := {
case PathList("META-INF", _) => MergeStrategy.discard
case PathList("BUILD") => MergeStrategy.discard
case path =>
if (ignoreFiles.contains(path))
MergeStrategy.discard
else
(assemblyMergeStrategy in assembly).value(path)
},
imageNames in docker := Seq(
// Sets the latest tag
ImageName(s"ledgerhq/${name.value}:latest"),
// Sets a name with a tag that contains the project version
ImageName(
namespace = Some("ledgerhq"),
repository = name.value,
tag = Some("v" + version.value)
)
),
// User `docker` to build docker image
dockerfile in docker := {
// The assembly task generates a fat JAR file
val artifact: File = assembly.value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("openjdk:8-jre")
add(artifact, artifactTargetPath)
entryPoint("java", "-jar", artifactTargetPath)
}
}
)