forked from codacy/codacy-phpmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
71 lines (54 loc) · 2.06 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
import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd}
name := """codacy-engine-phpmd"""
version := "1.0-SNAPSHOT"
val languageVersion = "2.11.7"
scalaVersion := languageVersion
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases",
"Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
)
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.3.8" withSources(),
"org.scala-lang.modules" %% "scala-xml" % "1.0.4" withSources(),
"com.codacy" %% "codacy-engine-scala-seed" % "2.7.1",
"com.github.pathikrit" %% "better-files" % "2.16.0"
)
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
version in Docker := "1.0"
val installAll =
s"""
|export COMPOSER_HOME=/opt/composer &&
|mkdir -p $$COMPOSER_HOME &&
|apk --no-cache add bash curl git php php-xml php-cli php-pdo php-curl php-json php-phar php-ctype php-openssl php-dom &&
|curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin --filename=composer &&
|composer global require "phpmd/phpmd=2.6.0" &&
|chmod -R 777 /opt &&
|ln -s /opt/composer/vendor/bin/phpmd /bin/phpmd &&
|apk del curl git
|rm -rf /var/cache/apk/*
""".stripMargin.replaceAll(System.lineSeparator(), " ")
mappings in Universal <++= (resourceDirectory in Compile) map { (resourceDir: File) =>
val src = resourceDir / "docs"
val dest = "/docs"
for {
path <- (src ***).get
if !path.isDirectory
} yield path -> path.toString.replaceFirst(src.toString, dest)
}
val dockerUser = "docker"
val dockerGroup = "docker"
daemonUser in Docker := dockerUser
daemonGroup in Docker := dockerGroup
dockerBaseImage := "develar/java"
dockerCommands := dockerCommands.value.flatMap {
case cmd@Cmd("WORKDIR", _) => List(cmd,
Cmd("RUN", installAll)
)
case cmd@(Cmd("ADD", "opt /opt")) => List(cmd,
Cmd("RUN", "mv /opt/docker/docs /docs"),
Cmd("RUN", s"adduser -u 2004 -D $dockerUser"),
ExecCmd("RUN", Seq("chown", "-R", s"$dockerUser:$dockerGroup", "/docs"): _*)
)
case other => List(other)
}