Deploying a full stack Scala application on Heroku

Heroku and Scala logos

Project structure

- project
- backend
-- src
- frontend
-- src
-- webpack
- shared
-- src

Compiling the frontend

Create the app

heroku apps:create APP_NAME --region eu
heroku addons:create heroku-postgresql:hobby-dev

The sbt-Heroku plugin

addSbtPlugin("com.heroku" % "sbt-heroku" % "2.1.3")
lazy val `backend` = (project in file("./backend"))
.enablePlugins(PlayScala) // for example
herokuAppName in Compile := "APP_NAME",
herokuProcessTypes in Compile := Map(
"web" -> "target/universal/stage/bin/backend -Dhttp.port=$PORT" // command for Heroku to launch the server
//"worker" -> "java -jar target/universal/stage/lib/my-worker.jar"
herokuIncludePaths in Compile := Seq(
// [...]
stage := {
val webpackValue = (frontend / Compile / fullOptJS / webpack).value
println(s"Webpack value is $webpackValue")
(stage in backend).value

Accessing the database


Specific to Play

Wrap up



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store