Exclude Metals from your Docker builds of Scala projects
Metals is a Scala language server. It gives your editor IDE-like abilities.
In one project it was failing to start, which was causing me much head scratching because a Docker build of the same project also started failing. What’s the Docker build got to do with my editor?
Doug spotted the source of the problem: it was other tooling, Bloop, that Metals was using. It was trying to generate something when sbt (the Scala build tool) started. Bloop was introducing incompatibilities to my project.
This problematic configuration can be excluded via .dockerignore. I didn’t know about this file before, and that is indeed the solution.
The way to exclude it is:
$ cat .dockerignore
.bloop
**/metals.sbt
.metals
I think it’s only the **/metals.sbt line that you need.
I’ll do this all the time, because my Docker builds won’t need to invoke IDE tooling integration.