Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT: Slow resolution and failures when doing builds within Docker containers

I have a simple Play! application with nothing special going on in the build.sbt;

name := """project-name"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  jdbc,
  javaJdbc,
  javaEbean,
  "mysql" % "mysql-connector-java" % "5.1.38",
  cache,
  ws,
  "com.googlecode.libphonenumber" % "libphonenumber" % "7.1.0"
)

// string metrics
libraryDependencies += "com.rockymadden.stringmetric" %% "stringmetric-core" % "0.27.4"

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

And inside a Dockerfile I'm attempting to build an executable of this application via the activator dist, sbt dist or activator stage commands.

All of the above work flawlessly when I run it on my computer. However, when I run exactly the same commands from within a docker container, I notice;

  • SBT takes very long to resolve dependencies, it goes very slowly through the list of dependencies.
  • The build fails with the following: sbt.ResolveException: download failed: org.scalaz#scalaz-core_2.10;7.0.2!scalaz-core_2.10.jar(bundle)

I'm doubting if this is an error that has to do with SBT or something specific to Docker containers. Has anyone seen this before?

like image 459
Ashesh Avatar asked Jan 21 '16 13:01

Ashesh


People also ask

Why is Docker container so slow?

When you experience slow Docker performance, check your CPU, memory usage, and available disk space. Consider upgrading your system if a component does not perform as expected. When dealing with a specific container that is performing worse than expected, it may be helpful to check container-specific metrics.

How do I speed up Docker build time?

The easiest way to increase the speed of your Docker image build is by specifying a cached image that can be used for subsequent builds. You can specify the cached image by adding the --cache-from argument in your build config file, which will instruct Docker to build using that image as a cache source.

How do I fix OOM issue in a Docker container?

By default, if an out-of-memory (OOM) error occurs, the kernel kills processes in a container. To change this behavior, use the --oom-kill-disable option. Only disable the OOM killer on containers where you have also set the -m/--memory option.

How do I make my Docker use less RAM?

To limit the maximum amount of memory usage for a container, add the --memory option to the docker run command. Alternatively, you can use the shortcut -m . Within the command, specify how much memory you want to dedicate to that specific container.


1 Answers

Mounting the .ivy2 and .sbt directories in the container increased the compiling speed significantly:

-v ~/.sbt:/root/.sbt -v ~/.ivy2:/root/.ivy2
like image 133
030 Avatar answered Oct 01 '22 14:10

030