$ docker-compose build
$ docker-compose run scala sbt compile
$ docker-compose run scala sbt run
$ docker-compose run scala sbt test
$ docker-compose run scala sbt "~ test" # to run continuously
$ docker-compose run scala # to access Docker's Machine
$ docker-compose run scala sbt ~compile # similar to test above. Works with and without quotes
It may take a while to fetch all dependencies (libs) based on what's inside your|project build.sbt
project file.
This configuration shares a local .sbt
and .ivy2
directories with Docker's Container /root/.sbt
and /root/.ivy2
directories.
With sharing, sbt
will find your dependencies' cache and will not re-download everything again.
This Dockerfile is based on Scala-sbt Dockerfile from Docker Hub
Put both .sbt
and .ivy2
directories under your .gitignore
file.
To update Scala/SBT to latest version, remember to remove the old image. You can find it $ docker images
and remove the base image named hseeberger/scala-sbt
using command $ docker rmi <image-hash-id>
, then, build again. You can check which is the latest version here Scala-sbt Dockerfile from Docker Hub
Shouldn't the WORKDIR instruction be after the COPY in the Dockerfile?