Search code examples
scalasbtdockerthoughtworks-go

Docker Data Volume for SBT Dependencies


I am using docker for continuous integration of a Scala project. Inside the container I am building the project and creating a distribution with "sbt dist".

This takes ages pulling down all the dependencies and I would like to use a docker data volume as mentioned here: http://docs.docker.io/en/latest/use/working_with_volumes/

However, I don't understand how I could get SBT to put the jar files in the volume, or how SBT would know how to read them from that volume.


Solution

  • SBT uses ivy to resolve project dependencies. Ivy caches downloaded artifacts locally and every time it is asked to pull something, it first goes to that cache and if nothing found downloads from remote. By default cache is located in ~/.ivy2, but it is actually a configurable property. So just mount volume, point ivy to it (or mount it in a way it will be on default location) and enjoy the caches.