Heroku Play Framework Support
Last updated May 15, 2023
This document describes the general behavior of the Heroku stack as it relates to the recognition and execution of Play framework applications. Play framework applications written in either Java or Scala can be run on Heroku.
Get started with Scala/Play 2.x on Heroku
Activation
Heroku Play framework support will be applied to applications that match: */conf/application.conf
in any directory except for the modules directory
When a deployed application is recognized as a Play application, Heroku responds -----> Play! app detected
for Play 1.2.x apps, -----> Play 2.x - Java app detected
for Play 2.x Java apps, or -----> Play 2.x - Scala app detected
for Play 2.x Scala apps. Play 2.x language detection is based on file count and is for informational purposes only.
$ git push heroku master
-----> Play! app detected
Build behavior
Play 2.x uses sbt to build your application behind the scenes. On Heroku sbt will be called directly to build your app:
sbt compile stage
The following directories are dropped from the slug after compilation, as they are not required at runtime:
- Ivy cache (persisted between builds of the same app)
project/boot
target/scala-*
target/streams
target/resolution-cache
Runtime behavior
Heroku currently uses OpenJDK to run your application. OpenJDK 8 is the default, while other versions are available using a system.properties
file. See the Java Tutorials for more information.
Play 2.0.x-2.1.x
A start script is generated by the xbst-start-script-plugin. This start script is used by the default web
process definition:
web: target/start -Dhttp.port=$PORT $JAVA_OPTS
Play 2.2+
The default web process is determined by examining output from the native packager plugin. If your app only contains one process, the following default web process is generated:
web: target/universal/stage/bin/{your project name} -Dhttp.port=$PORT
Note: JAVA_OPTS
is read by the generated script and does not need to be passed into the process.
Supported versions
Play 2.x relies on sbt dependency resolution so all versions are available as soon as they are released.
Add-ons
A Postgres database is automatically provisioned for Play framework applications. This populates the DATABASE_URL environment variable.