When you need to build your Scala project, but have no way to install SBT on your host, you can still do it if you have Docker.
There are few ready to use container images on DockerHub. We create our own.
All we need for that is to prepare a Dockerfile:
MAINTAINER Nikolay Kushin email@example.com
ENV SCALA_VERSION 2.11.7
ENV SBT_VERSION 0.13.9
ENV SBT_OPTS -Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M -Duser.timezone=GMT
# install sbt
RUN wget https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb
RUN dpkg -i sbt-$SBT_VERSION.deb
# install scala
RUN wget https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.deb
RUN dpkg -i scala-$SCALA_VERSION.deb
# fetch base dependencies
RUN sbt compile
Our Dockerfile is relatively easy and self-explaining.
Next step is to build an image. Save Dockerfile in some folder and execute following commande in terminal:
docker build -t sbt-docker .
Now when the image is ready we can create container with mounted source folder, containing our Scala project and run SBT.
docker run -it --rm -v $(pwd):/src sbt-docker sbt docker:stage
Thats it! Enjoy!