Does sbt dist compile the code or just copies files from target directory

584 Views Asked by At

I have a Play Framework/Scala application. I want to make a production version of the application. I want do dockerise the application

If I run sbt dist to create production version of my application, would sbt compile and build the code and also include application specific files (eg. logback.xml and application.conf) in the package or does it just pick all files from target folder and convert them into a zip file?

I am wondering if I need to copy the configuration and logging files explicitly in Dockerfile

1

There are 1 best solutions below

0
Manu Chadha On

So I have found that (a) sbt dist does compile the code. Also my main problem was that my sbt task to create a deployable version of my application wasn't working. I had written an sbt task in build.sbt

lazy val `create-deployable` = taskKey[Unit]("create dist for deployment")
`create-deployable` := {
  implicit val root = baseDirectory.value
  if (createDist != 0) { println(s"got error ${createDist}");throw new Exception("Couldn't create dist. failed!")}
}

def createDist(implicit dir: File): Int = runScript("dist")

But when I would run it, I would get error dist not found. I changed it to sbt dist but then the error would be sbt not found. The issue was that the run the script, I was using cmd /c and the cmd console couldn't find sbt installed on my laptop.

The correct way to run sbt tasks is to (1) create an sbt task from Edit Configurations (2) give it a name (3) check that use sbt shell option is checked (4) give the task name which sbt recognises.

Eg.

enter image description here