Installing Scala
First, you’ll probably want to install Scala. To do this, add a new file to your repository called .gitpod.Dockerfile, and add the following content to it:What are these files for?
Let’s break this down. First, in.gitpod.Dockerfile
, we declare FROM gitpod/workspace-full
to have your project use Gitpod’s default workspace image (recommended). You can use other images too, but some Gitpod features might not work as well with untested images.
Next, we declare RUN brew install scala
. This simply installs Scala into the workspace image via HomeBrew.
Then, we register our custom Dockerfile in Gitpod’s configuration file .gitpod.yml
, so that Gitpod knows it should pick it up and build it on-the-fly when booting up new workspaces.
Finally, please note that these changes will only take effect in new workspaces. To try out your new automated dev setup, simply commit both files; push them to GitHub; and then open a new Gitpod workspace for your repository. 🚀
Using the Ammonite REPL

amm
in the terminal, and behold a super cool Scala REPL in your workspace!
Building projects with sbt
To use sbt (simple build tool) in Gitpod, you can add the following to that .gitpod.Dockerfile we created:sbt
will be installed in all future workspaces.
Managing Scala versions with scalaenv
Say your project needs a specific Scala version. You can use scalaenv, a version manager for Scala, to switch between different Scala versions. But first, we must installscalaenv
. As usual, we need to change our .gitpod.Dockerfile, by adding this to it:
2.12.11
, you would add the following line as well:
Using coursier, an artifact fetcher for Scala
coursier is useful for building certain Scala projects and installing different tools.Formatting Scala code with scalafmt
To install scalafmt for your repository, add the following to your .gitpod.Dockerfile:scalafmt
!
Putting it all together
A full example of a .gitpod.Dockerfile configured for Scala could look something like:brew install
commands are on the same line. We recommend grouping similar commands together to minimize the number of Docker layers.
Additionally, your .gitpod.yml file should still look like this:
VS Code Extensions
Scala Syntax (official)

sbt
files.
To get it, open Gitpod’s Extensions panel (left vertical menu in the IDE), then search for “Scala Syntax”, and install it “for this project”. Then, commit the automatic .gitpod.yml
change that was made by Gitpod.
Metals

.gitpod.yml
change that was made by Gitpod.
Boom! You’re done! (Just a reminder, don’t forget to push the changes.)