Search code examples
scaladockerplayframeworksbtwebjars

SBT incremental compilation with WebJars inside Docker


I am working on Play! application with Angular 2 and webjars dependencies. SBT play plugin and typescript plugin. I use incremental compilation, but it takes great amount of time on each recompilation. I set "sbt-optimizer" to check which tasks are longest one. And i see that on each recompilation WebJars are taking almost all the recompile time. I can't imagine why he needs to do something with static files after first compilation. But even if i change scala file or twirl template, it does not matter again all webjars.

UPD: If i run on machine without Docker then speed is normal - recompile take few seconds. Inside Docker - 200sec+.

Compilation messages without docker - 2s, inside docker - 13s. Operations on screen without docker 10-300ms inside docker 500-60000ms.

UPD: Adding my docker file

FROM openjdk:8

ENV SCALA_VERSION=2.12.1
ENV SBT_VERSION=0.13.13
ENV NODEJS_VERSION=6.10.0

# Install sbt
RUN cd /tmp && \
wget https://dl.bintray.com/sbt/native-packages/sbt/$SBT_VERSION/sbt-$SBT_VERSION.zip && \
unzip sbt-$SBT_VERSION.zip -d /usr/local && \
rm sbt-$SBT_VERSION.zip

#install nodejs for web jars
RUN cd /tmp && \
wget https://nodejs.org/dist/v$NODEJS_VERSION/node-v$NODEJS_VERSION-linux-x64.tar.xz && \
tar -C /usr/local --strip-components 1 -xJf node-v$NODEJS_VERSION-linux-x64.tar.xz &&
rm node-v$NODEJS_VERSION-linux-x64.tar.xz

Here is printout from optimizer: enter image description here

May be i missed something, or someone had such problems, why SBT do that each time, and how can i prevent this?

Thank you


Solution

  • If you are running a mounted volume on Docker for Mac, you're probably hitting this issue with performance of mounted volumes.