-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sbt
executable file
·64 lines (49 loc) · 1.83 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
import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd}
import sjsonnew.BasicJsonProtocol._
import sjsonnew._
import sjsonnew.support.scalajson.unsafe._
name := "codacy-csslint"
scalaVersion := "2.13.1"
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.7.4" withSources (),
"org.scala-lang.modules" %% "scala-xml" % "1.2.0" withSources (),
"com.codacy" %% "codacy-engine-scala-seed" % "5.0.1" withSources ()
)
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
lazy val toolVersionKey = settingKey[String]("The version of the underlying tool retrieved from patterns.json")
toolVersionKey := {
case class Patterns(name: String, version: String)
implicit val patternsIso: IsoLList[Patterns] =
LList.isoCurried((p: Patterns) => ("name", p.name) :*: ("version", p.version) :*: LNil) {
case (_, n) :*: (_, v) :*: LNil => Patterns(n, v)
}
val jsonFile = (resourceDirectory in Compile).value / "docs" / "patterns.json"
val json = Parser.parseFromFile(jsonFile)
val patterns = json.flatMap(Converter.fromJson[Patterns])
patterns.get.version
}
mappings in Universal ++= {
(resourceDirectory in Compile) map { resourceDir: File =>
val src = resourceDir / "docs"
val dest = "/docs"
for {
path <- src.allPaths.get if !path.isDirectory
} yield path -> path.toString.replaceFirst(src.toString, dest)
}
}.value
val dockerUser = "docker"
val dockerGroup = "docker"
daemonUser in Docker := dockerUser
daemonGroup in Docker := dockerGroup
dockerBaseImage := "codacy-csslint-base"
dockerCommands := dockerCommands.value.flatMap {
case cmd @ (Cmd("ADD", _)) =>
List(
Cmd("RUN", "adduser -u 2004 -D docker"),
cmd,
Cmd("RUN", "mv /opt/docker/docs /docs"),
ExecCmd("RUN", Seq("chown", "-R", s"$dockerUser:$dockerGroup", "/docs"): _*)
)
case other => List(other)
}