forked from codeclimate-community/codeclimate-scalastyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
78 lines (61 loc) · 2.34 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
name := "codeclimate-scalastyle"
organization in ThisBuild := "codeclimate"
version in ThisBuild := "0.1.1"
scalaVersion in ThisBuild := "2.12.2"
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)
parallelExecution in Global := false
lazy val `engine-core` = project settings (
libraryDependencies ++= Seq(
"org.scalastyle" %% "scalastyle" % "1.0.0",
"io.circe" %% "circe-parser" % "0.8.0",
"io.circe" %% "circe-generic" % "0.8.0",
"com.github.scopt" %% "scopt" % "3.7.0",
"org.scalactic" %% "scalactic" % "3.0.4",
"org.scalatest" %% "scalatest" % "3.0.4" % "test"
)
)
lazy val `codeclimate-scalastyle` = project in file(".") dependsOn `engine-core`
resolvers in ThisBuild ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
)
enablePlugins(sbtdocker.DockerPlugin)
imageNames in docker := Seq(
// Sets the latest tag
ImageName(s"codeclimate/${name.value}:latest"),
// Sets a name with a tag that contains the project version
ImageName(
namespace = Some("codeclimate"),
repository = name.value,
tag = Some(version.value)
)
)
dockerfile in docker := {
val dockerFiles = {
val resources = (unmanagedResources in Runtime).value
val dockerFilesDir = resources.find(_.getPath.endsWith("/docker")).get
resources.filter(_.getPath.contains("/docker/")).map { r =>
(dockerFilesDir.toURI.relativize(r.toURI).getPath, r)
}.toMap
}
new Dockerfile {
from("openjdk:alpine")
// add all dependencies to docker image instead of assembly (layers the dependencies instead of huge assembly)
val dependencies = {
((dependencyClasspath in Runtime) in `engine-core`).value
}.map(_.data).toSet + ((packageBin in Compile) in `engine-core`).value
maintainer("Jeff Sippel", "[email protected]")
maintainer("Ivan Luzyanin", "[email protected]")
add(dependencies.toSeq, "/usr/src/app/dependencies/")
add(((packageBin in Compile) in `engine-core`).value, "/usr/src/app/engine-core.jar")
add(dockerFiles("scalastyle_config.xml"), "/usr/src/app/")
add(dockerFiles("engine.json"), "/")
add(dockerFiles("bin/scalastyle"), "/usr/src/app/bin/")
runRaw("apk update && apk upgrade")
runRaw("addgroup -g 9000 -S code && adduser -S -G code app")
user("app")
workDir("/code")
volume("/code")
cmd("/usr/src/app/bin/scalastyle")
}
}