DEV Community


Deploying Grails 4 to Heroku

erichelgeson profile image Eric Helgeson ・2 min read

Heroku is a PaaS(Platform as a Service) for running web apps that makes it as simple as a git push to deploy. They offer a free tier that is great for demos or quick testing environments and services such as redis, postgres, and many others.

There are a few minor changes from the default heroku gradle build pack to get your Grails 4 app run.

By default heroku will run the task stage to get your app ready. You could add a gradle task named stage or change the default task by running:

$ heroku config:set GRADLE_TASK="assemble"

The Procfile is used to tell heroku how to start your app, in this case, we need to pass the dynamically assigned port to our app, along with heroku's JAVA_OPTS. Lastly, tell it where gradle put our war/jar.


web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/*.war

If you'd like to run on OpenJDK 11 - create a file with the following:


And thats it. Push to Heroku and your app will build and deploy in about a minute.

$ git push heroku master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 227 bytes | 227.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: -----> Gradle app detected
remote: -----> Installing JDK 11... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew assemble
remote:        > Task :compileJava NO-SOURCE
remote:        > Task :compileGroovy
remote:        > Task :buildProperties
remote:        > Task :processResources
remote:        > Task :classes
remote:        > Task :compileGsonViews
remote:        > Task :findMainClass
remote:        > Task :bootWar
remote:        > Task :war SKIPPED
remote:        > Task :assemble
remote:        BUILD SUCCESSFUL in 25s
remote:        6 actionable tasks: 6 executed
remote: -----> Discovering process types
remote:        Procfile declares types -> (none)
remote: -----> Compressing...
remote:        Done: 117.2M
remote: -----> Launching...
remote:        Released v21
remote: deployed to Heroku
remote: Verifying deploy... done.
   905744b..b239ff4  master -> master

See also:

Discussion (0)

Editor guide