Deploy Grails Applications on Heroku
Posted by Jesper
Grails is a high-productivity web application framework for the JVM based on the Groovy programming language and featuring many similarities with Rails. Since its inception in 2006, the framework has enjoyed broad adoption in the Java community as it combines the strengths of the JVM and richness of the Java platform with the productivity benefits of modern frameworks like Rails.
Today the Grails team announced Grails 2.0, the latest incarnation of the framework. It features numerous large improvements including an overhauled command line tool, faster and more reliable reloads, and static asset support. Details are covered in the What's New section of the Grails docs.
The release includes the Grails Heroku plugin that provides simple commands to set up your Grails app with Heroku add-on services like Postgres, Memcached, Redis, MongoDB from MongoLabs or MongoHQ and RabbitMQ.
Deploying a Grails app on Heroku
Create a new Grails project:
$ grails createApp HelloWorld | Created Grails Application at /Users/jjoergensen/dev/HelloWorld $ cd HelloWorld
Commit to Git:
$ grails integrate-with --git $ git init Initialized empty Git repository in /Users/jjoergensen/dev/HelloWorld/.git/ $ git add . $ git commit -m init [master (root-commit) bd0f36b] init 58 files changed, 2788 insertions(+), 0 deletions(-) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project ...
Create Heroku Cedar app:
$ heroku create --stack cedar Creating smooth-night-8061... done, stack is cedar http://smooth-night-8061.herokuapp.com/ | email@example.com:smooth-night-8061.git Git remote heroku added
Deploy to Heroku:
$ git push heroku master Counting objects: 73, done. Delta compression using up to 4 threads. Compressing objects: 100% (69/69), done. Writing objects: 100% (73/73), 97.82 KiB, done. Total 73 (delta 2), reused 0 (delta 0) -----> Heroku receiving push -----> Grails app detected -----> Grails 2.0.0 app detected -----> Installing Grails 2.0.0..... done -----> executing grails -plain-output -Divy.default.ivy.user.dir=/app/tmp/repo.git/.cache war |Loading Grails 2.0.0. ... |Done creating WAR target/HelloWorld-0.1.war -----> No server directory found. Adding jetty-runner 7.5.4.v20111024 automatically. -----> Discovering process types Procfile declares types -> (none) Default types for Grails -> web -----> Compiled slug size is 30.6MB -----> Launching... done, v3 http://smooth-night-8061.herokuapp.com deployed to Heroku