-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.sbt
109 lines (97 loc) · 3.73 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
103
104
105
106
107
108
109
/**
* PROPRIETARY AND CONFIDENTIAL
*
* Unauthorized copying of this file via any medium is strictly prohibited.
*
* Copyright (c) 2019-2022 Snowplow Analytics Ltd. All rights reserved.
*/
import com.typesafe.sbt.packager.MappingsHelper.directory
import com.typesafe.sbt.packager.docker.*
import scala.collection.Seq
lazy val buildSettings = Seq(
name := "snowplow-micro",
organization := "com.snowplowanalytics.snowplow",
description := "Standalone application to automate testing of trackers",
scalaVersion := "2.12.14",
scalacOptions := Settings.compilerOptions,
javacOptions := Settings.javaCompilerOptions,
Runtime / unmanagedClasspath ++= Seq(
baseDirectory.value / "config",
baseDirectory.value / "ui" / "out"
),
Compile / unmanagedResources += file("LICENSE.md"),
resolvers ++= Dependencies.resolvers,
Test / parallelExecution := false
)
lazy val dependencies = Seq(
libraryDependencies ++= Seq(
Dependencies.snowplowStreamCollector,
Dependencies.snowplowCommonEnrich,
Dependencies.decline,
Dependencies.http4sCirce,
Dependencies.circeJawn,
Dependencies.circeGeneric,
Dependencies.specs2,
Dependencies.specs2CE,
Dependencies.badRows
)
)
lazy val buildInfoSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](name, moduleName, dockerAlias, version, "shortName" -> "micro-ssc"),
buildInfoPackage := "com.snowplowanalytics.snowplow.micro",
buildInfoOptions += BuildInfoOption.Traits("com.snowplowanalytics.snowplow.collector.core.AppInfo")
)
lazy val dynVerSettings = Seq(
ThisBuild / dynverVTagPrefix := false, // Otherwise git tags required to have v-prefix
ThisBuild / dynverSeparator := "-" // to be compatible with docker
)
lazy val commonSettings =
dependencies ++
buildSettings ++
buildInfoSettings ++
dynVerSettings ++
Settings.licenseSettings ++
Settings.dynverOptions ++
Settings.assemblyOptions
lazy val dockerCommon = Seq(
Docker / maintainer := "Snowplow Analytics Ltd. <[email protected]>",
Docker / packageName := "snowplow/snowplow-micro",
Docker / defaultLinuxInstallLocation := "/opt/snowplow",
Docker / daemonUserUid := None,
dockerPermissionStrategy := DockerPermissionStrategy.CopyChown,
dockerRepository := Some("snowplow"),
Universal / mappings += file("LICENSE.md") -> "/SNOWPLOW-LICENSE.md"
)
lazy val microSettingsDistroless = dockerCommon ++ Seq(
dockerBaseImage := "gcr.io/distroless/java11-debian11:nonroot",
Docker / daemonUser := "nonroot",
Docker / daemonGroup := "nonroot",
dockerEntrypoint := Seq(
"java",
"-Dnashorn.args=--language=es6",
"-cp",
s"/opt/snowplow/lib/${(packageJavaClasspathJar / artifactPath).value.getName}:/opt/snowplow/ui:/config",
"com.snowplowanalytics.snowplow.micro.Main"
),
Universal / mappings ++= directory((micro / baseDirectory).value / "ui" / "out").map {
case (source, destination) => (source, destination.replaceFirst("^out/", "ui/"))
},
sourceDirectory := (micro / sourceDirectory).value
)
lazy val microSettings = dockerCommon ++ Seq(
dockerBaseImage := "eclipse-temurin:11",
Docker / daemonUser := "daemon",
scriptClasspath ++= Seq("/opt/snowplow/ui", "/config"),
Universal / javaOptions ++= Seq("-Dnashorn.args=--language=es6"),
Universal / mappings ++= directory(baseDirectory.value / "ui" / "out").map {
case (source, destination) => (source, destination.replaceFirst("^out/", "ui/"))
}
)
lazy val micro = project
.in(file("."))
.settings(commonSettings ++ microSettings)
.enablePlugins(BuildInfoPlugin, DockerPlugin, JavaAppPackaging)
lazy val microDistroless = project
.in(file("distroless/micro"))
.settings(commonSettings ++ microSettingsDistroless)
.enablePlugins(BuildInfoPlugin, DockerPlugin, JavaAppPackaging, ClasspathJarPlugin)