-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
130 lines (112 loc) · 4.45 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
val catsV = "2.5.5"
val catsEffectV = "2.3.0"
val http4sV = "0.21.34"
val catsEffectScalaTestV = "0.5.4"
val tapirV = "0.17.20"
val kindProjectorV = "0.13.2"
val betterMonadicForV = "0.3.1"
val logbackVersion = "1.2.11"
val circeV = "0.14.4"
val dynamodbV = "1.11.1034"
val testContainerV = "0.40.12"
// General Settings
inThisBuild(
List(
organization := "fp-in-bo",
developers := List(
Developer("azanin", "Alessandro Zanin", "[email protected]", url("https://github.com/azanin"))
),
homepage := Some(url("https://github.com/fp-in-bo/api")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
pomIncludeRepository := { _ => false }
)
)
// General Settings
lazy val commonSettings = Seq(
scalaVersion := "2.13.10",
scalafmtOnCompile := true,
addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorV cross CrossVersion.full),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % betterMonadicForV),
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % catsV,
"org.http4s" %% "http4s-dsl" % http4sV,
"org.http4s" %% "http4s-blaze-server" % http4sV,
"com.softwaremill.sttp.tapir" %% "tapir-core" % tapirV,
"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % tapirV,
"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % tapirV,
"io.circe" %% "circe-generic" % circeV,
"com.amazonaws" % "aws-java-sdk-dynamodb" % dynamodbV,
"ch.qos.logback" % "logback-classic" % logbackVersion % Runtime,
"com.codecommit" %% "cats-effect-testing-scalatest" % catsEffectScalaTestV,
"com.dimafeng" %% "testcontainers-scala-dynalite" % testContainerV,
"com.dimafeng" %% "testcontainers-scala-scalatest" % testContainerV,
"org.http4s" %% "http4s-blaze-client" % http4sV,
"org.http4s" %% "http4s-circe" % http4sV
)
)
// Projects
lazy val core = project
.in(file("core"))
.settings(commonSettings)
.settings(name := "api")
.settings(parallelExecution in Test := false)
.settings(test in assembly := {})
.settings(assemblyJarName in assembly := "fpinbo-rest-api.jar")
.settings(assemblyMergeStrategy in assembly := {
case PathList("META-INF", "maven", "org.webjars", "swagger-ui", "pom.properties") => MergeStrategy.singleOrError
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
})
.enablePlugins(DockerPlugin)
.settings(dockerfile in docker := {
dockerFile(assembly.value)
})
.settings(
imageNames in docker := Seq(
// Sets the latest tag
ImageName(
namespace = Some(organization.value + "/api"),
repository = "fp-in-bo-api",
registry = Some("ghcr.io"),
tag = Some("latest")
), // Sets a name with a tag that contains the project version
ImageName(
namespace = Some(organization.value + "/api"),
repository = "fp-in-bo-api",
registry = Some("ghcr.io"),
tag = Some("v" + version.value.replace('+', '-'))
)
)
)
.settings(
publish in docker := Some("Github container registry" at "https://ghcr.io")
)
lazy val tests = project
.in(file("tests"))
.settings(name := "tests")
.configs(IntegrationTest)
.settings(Defaults.itSettings)
.settings(commonSettings)
.settings(parallelExecution in IntegrationTest := false)
.enablePlugins(NoPublishPlugin)
.settings(fork in IntegrationTest := true)
.enablePlugins(DockerPlugin)
.settings(dockerfile in docker := dockerFile((assembly in core).value))
.dependsOn(core)
lazy val api = project
.in(file("."))
.enablePlugins(NoPublishPlugin)
.aggregate(core, tests)
addCommandAlias("integrationTests", ";project tests;docker;it:test")
addCommandAlias("dockerBuildAndPublish", ";project core;dockerBuildAndPush")
def dockerFile(dependsOn: File) = {
val artifactTargetPath = s"/app/${dependsOn.name}"
new Dockerfile {
from("openjdk:11-jre")
add(dependsOn, artifactTargetPath)
entryPoint("java", "-jar", artifactTargetPath)
expose(80)
label("org.containers.image.source", "https://github.com/fp-in-bo/api")
}
}