-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
169 lines (152 loc) · 5.96 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots")
lazy val ProjectName = "KM8"
lazy val ProjectOrganization = "KM8S"
lazy val ProjectVersion = "0.2.0-SNAPSHOT"
lazy val ProjectScalaVersion = "3.1.2"
lazy val Versions = new {
val zio = "1.0.13"
val zioKafka = "0.17.5"
val zioJson = "0.2.0-M3"
val zioLogging = "0.5.14"
val zioPrelude = "1.0.0-RC8"
val kafkaProtobuf = "7.1.0"
val javaFx = "16"
val scalaFx = "16.0.0-R25"
val osLib = "0.8.1"
val circe = "0.14.1"
val sttp = "3.5.1"
val logback = "1.2.11"
val logstash = "7.1"
val testContainers = "0.40.5"
}
Global / onChangedBuildSource := ReloadOnSourceChanges
lazy val root = project
.in(file("."))
.aggregate(fx, common, core)
.settings(
name := ProjectName,
organization := ProjectOrganization,
version := ProjectVersion
)
.enablePlugins(DockerPlugin)
.disablePlugins(RevolverPlugin)
.settings(
docker := (docker dependsOn (core / assembly)).value,
docker / dockerfile := {
val artifact: File = (core / assembly / assemblyOutputPath).value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("openjdk:8-jre")
env("KAFKAMATE_ENV", "prod")
expose(8080, 61234, 61235)
runRaw(
"apt-get update && apt-get install -y dumb-init apt-transport-https ca-certificates curl gnupg2 software-properties-common"
)
runRaw("""curl -sL 'https://getenvoy.io/gpg' | apt-key add -""")
runRaw("""apt-key fingerprint 6FF974DB | grep "5270 CEAC" """)
runRaw(
"""add-apt-repository "deb [arch=amd64] https://dl.bintray.com/tetrate/getenvoy-deb $(lsb_release -cs) stable" """
)
runRaw("apt-get update && apt-get install -y getenvoy-envoy=1.15.1.p0.g670a4a6-1p69.ga5345f6")
add(artifact, artifactTargetPath)
copy(baseDirectory(_ / "site" / "build").value, "/usr/share/nginx/html/")
entryPoint("/usr/bin/dumb-init", "--")
cmd("./start.sh", artifactTargetPath)
}
},
docker / imageNames := Seq(
ImageName(s"${organization.value}/${name.value}:latest"),
ImageName(
repository = s"${organization.value}/${name.value}",
tag = Some(version.value)
)
)
)
.settings(
addCommandAlias("dockerize", ";compile;test;build;docker"),
addCommandAlias("fmt", "all scalafmtSbt scalafmtAll test:scalafmt"),
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")
)
lazy val javaFXModules = {
// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Windows") => "win"
case _ => throw new Exception("Unknown platform!")
}
Seq("base", "controls", "fxml", "graphics", "media", "swing", "web").map(m =>
"org.openjfx" % s"javafx-$m" % Versions.javaFx classifier osName
)
}
lazy val fx = project
.in(file("fx"))
.settings(sharedSettings)
.settings(
name := "KM8",
libraryDependencies ++= Seq(
"org.scalafx" %% "scalafx" % Versions.scalaFx,
"com.softwaremill.sttp.client3" %% "core" % Versions.sttp,
"com.softwaremill.sttp.client3" %% "httpclient-backend-zio1" % Versions.sttp,
"com.softwaremill.sttp.client3" %% "async-http-client-backend-zio1" % Versions.sttp
) ++ javaFXModules,
Compile / run / mainClass := Some("io.km8.fx.Main"),
assembly / assemblyMergeStrategy := {
case x if x endsWith "io.netty.versions.properties" => MergeStrategy.discard
case x if x endsWith "module-info.class" => MergeStrategy.discard
case x if x endsWith ".proto" => MergeStrategy.discard
case x if x startsWith "org/reactivestreams/" => MergeStrategy.first
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
},
assembly / test := {}
)
.dependsOn(common)
lazy val core = project
.in(file("core"))
.configs(IntegrationTest)
.settings(sharedSettings)
.settings(
name := "km8-core",
libraryDependencies ++= Seq(
"dev.zio" %% "zio-kafka" % Versions.zioKafka,
"dev.zio" %% "zio-json" % Versions.zioJson,
"dev.zio" %% "zio-logging-slf4j" % Versions.zioLogging,
"io.confluent" % "kafka-protobuf-serializer" % Versions.kafkaProtobuf,
"com.lihaoyi" %% "os-lib" % Versions.osLib,
"net.logstash.logback" % "logstash-logback-encoder" % Versions.logstash,
"ch.qos.logback" % "logback-classic" % Versions.logback,
"dev.zio" %% "zio-test" % Versions.zio % IntegrationTest,
"dev.zio" %% "zio-test-sbt" % Versions.zio % IntegrationTest,
"com.dimafeng" %% "testcontainers-scala-kafka" % Versions.testContainers % IntegrationTest
),
resolvers ++= Seq(
"Confluent" at "https://packages.confluent.io/maven/"
),
IntegrationTest / fork := true
)
.settings(Defaults.itSettings)
.dependsOn(common)
lazy val common = project
.in(file("common"))
.settings(sharedSettings)
.disablePlugins(RevolverPlugin)
lazy val sharedSettings = Seq(
version := ProjectVersion,
scalaVersion := ProjectScalaVersion,
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-encoding",
"utf8"
),
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % Versions.zio,
"dev.zio" %% "zio-prelude" % Versions.zioPrelude,
"io.circe" %% "circe-generic" % Versions.circe,
"dev.zio" %% "zio-test" % Versions.zio % Test,
"dev.zio" %% "zio-test-sbt" % Versions.zio % Test
),
testFrameworks ++= Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
)