Public | Automated Build

Last pushed: 2 years ago
Short Description
Build sbt using Docker
Full Description

Using sbt inside Docker


sbt-dockerd is an Docker image to build the latest, development version of sbt.

Introduction

This image contains the latest, development version of sbt aka sbt 0.13.10-SNAPSHOT with Oracle JDK (Java SE Development Kit 8u60) installed via webupd8team PPA and $JAVA_HOME set system-wide (borrowed from cloudesire/java).

For more information on sbt, see the official sbt site.

You can use the image to work with your Scala projects using the "latest" version of sbt (without anything to install but Docker alone).

Please note that since the image can obviously be a couple of days lagging after the development of sbt. The repository the image comes from contains the Dockerfile to build the version of sbt from the day you run the build.

The aim of the project is showcase how to have reproducible builds of sbt without relying on proper shared directories like ~/.sbt/0.13 or ~/.ivy2 (that might get stalled after previous builds or similar cases).

Once built, the image can serve as a testing development environment before switching to the version of sbt in your projects. Work with the latest sbt in your projects using the image until you're ready to do the permanent switch for the entire team.

Prerequisites

  • A running Docker environment

Usage

The following docker run command executes sbt in the current directory on the host, but inside a Docker container. Any changes of the files or directories in the shared directory in the container are already available on the local machine.

$ docker run -it --rm -v $(pwd):/scala-project jaceklaskowski/docker-builds-sbt

where $(pwd) resolves to your current working directory with the Scala/sbt project of yours.

➜  docker-builds-sbt git:(master) ✗ docker run -it --rm -v $(pwd):/scala-project docker-builds-sbt
[info] Set current project to scala-project (in build file:/scala-project/)
> about
[info] This is sbt 0.13.10-SNAPSHOT
[info] The current project is {file:/scala-project/}scala-project 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.5
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.5

Mac OS X users: Please read Mount a host directory as a data volume where it talks about auto-sharing /Users directory and so you have to use $(pwd) (not .).

Building the image (with the very latest sources of sbt)

Execute docker build command to build the image on your own Docker host. Since a part of the build process is to pull the sbt sources from the repository, the image is as fresh as it could ever be.

$ docker build -t docker-builds-sbt:latest .

Execute the command every change in sbt's 0.13 branch.

Running Docker host on Mac OS

  1. Create a new Docker machine using Docker Machine, i.e. docker-machine create command.
  2. Execute docker-machine start dev to start the Docker host.
  3. eval "$(docker-machine env dev)" to have the command line set up.
  4. Execute docker ps to verify the setup. It should return an empty list of containers.

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author.

Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

License

This code is open source software licensed under the Apache 2.0 License.

Docker Pull Command
Owner
jaceklaskowski

Comments (0)