-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
102 lines (87 loc) · 3.54 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import sbt.Keys.version
import sbt._
enablePlugins(JavaAppPackaging)
val JDK = "1.8"
val buildNumber = scala.util.Properties.envOrNone("version").map(v => "." + v).getOrElse("")
val hydraNotificationsVersion = "0.1.0" + buildNumber
val registryUrl = sys.env.getOrElse("DOCKER_REGISTRY_URL", "")
updateOptions := updateOptions.value.withGigahorse(false)
lazy val dockerSettings = Seq(
buildOptions in docker := BuildOptions(
cache = false,
removeIntermediateContainers = BuildOptions.Remove.Always,
pullBaseImage = BuildOptions.Pull.IfMissing
),
dockerfile in docker := {
val appDir: File = stage.value
val targetDir = "/opt/hydra-notifications-server"
val portNumber = sys.env.getOrElse[String]("PORT_NUMBER", "8080").toInt
new Dockerfile {
from("java")
maintainer("Alex Silva <[email protected]>")
user("root")
env("JAVA_OPTS", "-Xmx4G")
run("mkdir", "-p", "/var/log/hydra")
expose(portNumber)
entryPoint(s"$targetDir/bin/${executableScriptName.value}")
copy(appDir, targetDir)
}
},
imageNames in docker := Seq(
ImageName(s"$registryUrl/hydra-notifications:latest"),
ImageName(
namespace = Some(registryUrl),
repository = "hydra-notifications",
tag = Some(version.value)
)
)
)
lazy val defaultSettings = Seq(
organization := "pluralsight",
version := hydraNotificationsVersion,
scalaVersion := "2.12.3",
description := "Hydra Notifications API",
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
dependencyOverrides += "org.apache.commons" % "commons-lang3" % "3.9",
excludeDependencies += "org.slf4j" % "slf4j-log4j12",
excludeDependencies += "log4j" % "log4j",
packageOptions in(Compile, packageBin) +=
Package.ManifestAttributes("Implementation-Build" -> buildNumber),
logLevel := Level.Info,
scalacOptions ++= Seq("-encoding", "UTF-8", "-feature", "-language:_", "-deprecation", "-unchecked"),
javacOptions in Compile ++= Seq("-encoding", "UTF-8", "-source", JDK, "-target", JDK,
"-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options"),
resolvers += Resolver.mavenLocal,
resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Confluent Maven Repo" at "https://packages.confluent.io/maven/",
resolvers += "jitpack" at "https://jitpack.io",
coverageExcludedPackages := "hydra\\.ingest\\.HydraIngestApp.*",
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet
)
lazy val root = Project(
id = "hydra-notifications",
base = file(".")
).settings(defaultSettings)
.aggregate(server, client)
lazy val client = Project(
id = "client",
base = file("client")
).settings(defaultSettings, name := "hydra-notifications-client", libraryDependencies ++= Dependencies.clientDeps)
val serverSettings = defaultSettings ++ Seq(libraryDependencies ++= Dependencies.serverDeps) ++ Seq(
mainClass in Compile := Some("hydra.notifications.NotificationsService"),
javaOptions += "-Xmx2G"
)
val gitCommitString = SettingKey[String]("gitCommit")
gitCommitString := git.gitHeadCommit.value.getOrElse("Not Set")
lazy val server = Project(
id = "server",
base = file("server")
).dependsOn(client)
.settings(serverSettings, dockerSettings, name := "hydra-notifications-server")
.enablePlugins(JavaAppPackaging, sbtdocker.DockerPlugin, BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](version, gitCommitString),
buildInfoPackage := "buildInfo",
buildInfoOptions += BuildInfoOption.ToMap,
buildInfoOptions += BuildInfoOption.ToJson
)