-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sbt
160 lines (137 loc) · 4.39 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
import java.nio.file.Files
enablePlugins(JavaAppPackaging)
name := "bitcoin4s"
organization := "it.softfork"
version := "0.1.0"
ThisBuild / scalaVersion := "2.13.7"
ThisBuild / scalacOptions := Seq(
"-deprecation",
"-encoding",
"utf-8",
"-explaintypes",
"-feature",
"-unchecked",
"-Xsource:3",
"-Xlint:adapted-args",
"-Xlint:constant",
"-Xlint:delayedinit-select",
"-Xlint:doc-detached",
"-Xlint:inaccessible",
"-Xlint:infer-any",
"-Xlint:missing-interpolator",
"-Xlint:nullary-unit",
"-Xlint:option-implicit",
"-Xlint:package-object-classes",
"-Xlint:poly-implicit-overload",
"-Xlint:private-shadow",
"-Xlint:stars-align",
"-Xlint:type-parameter-shadow",
"-Xlint:nonlocal-return",
"-Xfatal-warnings",
"-Ywarn-dead-code",
"-Ywarn-extra-implicit",
"-Ywarn-numeric-widen",
"-Ywarn-unused:implicits",
"-Ywarn-unused:imports",
"-Ywarn-unused:locals",
"-Ywarn-unused:params",
"-Ywarn-unused:patvars",
"-Ywarn-unused:privates",
"-Ywarn-value-discard",
"-Ymacro-annotations"
)
Compile / console / scalacOptions --= Seq(
"-Ywarn-unused:imports",
"-Xfatal-warnings"
)
val scalastyleCfgFile = file("project/scalastyle-config.xml")
val scalastyleTestCfgFile = file("project/scalastyle-test-config.xml")
val akkaHttpVersion = "10.2.9"
val akkaVersion = "2.6.19"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-xml" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % "test",
"com.madgag.spongycastle" % "core" % "1.58.0.0",
"org.scodec" %% "scodec-core" % "1.11.9",
"com.iheart" %% "ficus" % "1.5.2",
"org.typelevel" %% "cats-core" % "2.7.0",
"org.typelevel" %% "simulacrum" % "1.0.1",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
"ch.qos.logback" % "logback-classic" % "1.2.11",
"org.scalatest" %% "scalatest" % "3.2.12" % "test",
"com.typesafe.play" %% "play-json" % "2.9.2",
"com.typesafe.play" %% "play-functional" % "2.9.2",
"de.heikoseeberger" %% "akka-http-play-json" % "1.39.2",
"org.julienrf" %% "play-json-derived-codecs" % "10.0.2",
"com.lihaoyi" %% "pprint" % "0.7.3"
)
resolvers ++= Seq(
Resolver.jcenterRepo
)
enablePlugins(sbtdocker.DockerPlugin, JavaAppPackaging)
docker / dockerfile := {
val appSource = stage.value
val appTarget = "/app"
val logsDir = appTarget + "/logs"
new Dockerfile {
from("openjdk:8-jre")
expose(8888)
workDir(appTarget)
runRaw(s"mkdir -p $logsDir && chown daemon:daemon $logsDir")
user("daemon")
volume(logsDir)
entryPoint(s"$appTarget/bin/${executableScriptName.value}")
copy(appSource, appTarget)
}
}
val baseImageName = "liuhongchao/bitcoin4s"
docker / imageNames := {
val branchNameOption =
sys.env.get("CI_COMMIT_REF_NAME").orElse(Option(git.gitCurrentBranch.value))
Seq(
branchNameOption.filter(_ == "master").map { _ =>
ImageName(baseImageName + ":latest")
},
branchNameOption.map { branch =>
ImageName(baseImageName + ":" + branch)
},
git.gitHeadCommit.value.map { commitId =>
ImageName(baseImageName + ":" + commitId)
}
).flatten
}
val buildFrontend = taskKey[Unit]("Build frontend")
buildFrontend := {
val exitCode =
scala.sys.process.Process(Seq("yarn", "run", "build"), file("client")).run().exitValue()
if (exitCode != 0) {
sys.error(s"Client build failed with exit code $exitCode")
}
}
stage := {
stage.dependsOn(buildFrontend).value
}
Compile / scalastyleConfig := scalastyleCfgFile
Test / scalastyleConfig := scalastyleTestCfgFile
Compile / resourceGenerators += Def.task {
val resourceBase = (Compile / resourceManaged).value / "client"
val sourceBase = file("client") / "build"
IO.delete(resourceBase)
sourceBase.allPaths.get.filter(_.isFile).map { file =>
val relative = file.relativeTo(sourceBase).get
val resourceFile = resourceBase / relative.toString
Files.createDirectories(resourceFile.toPath.getParent)
Files.copy(file.toPath, resourceFile.toPath)
resourceFile
}
}.taskValue
Revolver.enableDebugging(port = 5050, suspend = false)
addCommandAlias(
"format",
"scalafmtSbt;scalafmt;test:scalafmt;scalastyle;test:scalastyle"
)
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))