Skip to content

Commit

Permalink
Using the sbt-docker plugin.
Browse files Browse the repository at this point in the history
Note, still need to use the `docker` service in Travis, as you cannot
programmatically log in to private repositories, like Heroku. See
marcus-drake/sbt-docker#28 for more details.
  • Loading branch information
noelmarkham committed Oct 25, 2016
1 parent 927b344 commit 005034d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ after_success:
sbt publishSignedAll;
echo "Deploying to Heroku";
docker login --username=noel.m@47deg.com --password=$heroku_token registry.heroku.com;
docker build -t registry.heroku.com/scala-evaluator-sandbox/web .;
docker push registry.heroku.com/scala-evaluator-sandbox/web;
sbt dockerBuildAndPush;
fi
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
echo "Not in master branch, skipping deploy and release";
Expand Down
21 changes: 21 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ lazy val `evaluator-server` = (project in file("server"))
.dependsOn(`evaluator-shared-jvm`)
.enablePlugins(JavaAppPackaging)
.enablePlugins(AutomateHeaderPlugin)
.enablePlugins(sbtdocker.DockerPlugin)
.settings(noPublishSettings: _*)
.settings(
name := "evaluator-server",
Expand All @@ -78,7 +79,27 @@ lazy val `evaluator-server` = (project in file("server"))
),
assemblyJarName in assembly := "evaluator-server.jar"
)
.settings(dockerSettings)
.settings(compilerDependencySettings: _*)

onLoad in Global := (Command.process("project evaluator-server", _: State)) compose (onLoad in Global).value
addCommandAlias("publishSignedAll", ";evaluator-sharedJS/publishSigned;evaluator-sharedJVM/publishSigned;evaluator-clientJS/publishSigned;evaluator-clientJVM/publishSigned")

lazy val dockerSettings = Seq(
docker <<= docker dependsOn assembly,
dockerfile in docker := {

val artifact: File = assembly.value
val artifactTargetPath = artifact.name

sbtdocker.immutable.Dockerfile.empty
.from("ubuntu:latest")
.run("apt-get", "update")
.run("apt-get", "install", "-y", "openjdk-8-jdk")
.run("useradd", "-m", "evaluator")
.user("evaluator")
.add(artifact, artifactTargetPath)
.cmdRaw(s"java -Dhttp.port=$$PORT -jar $artifactTargetPath")
},
imageNames in docker := Seq(ImageName(repository = "registry.heroku.com/scala-evaluator-sandbox/web"))
)
2 changes: 1 addition & 1 deletion project/EvaluatorBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ object EvaluatorBuild extends AutoPlugin {

val projectName = Project.extract(s).currentProject.id

s"$blue$projectName$white>${c.RESET}"
s"$blue$projectName$white>${c.RESET} "
}
)

Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.6.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.12")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.4.0")

0 comments on commit 005034d

Please sign in to comment.