Deploying a Grails Application Using AppFog


Learn about the new Grails Academy magazine

Once your application is all tested and ready to go, you need to package it up and deploy it on a JVM application server. Hosting applications in the cloud is becoming more popular with platform services such as those offered by Amazon, Google, and others. One such free service that supports Grails is AppFog. AppFog’s free tier gives you 2 GB of RAM, and up to 8 provisioned services, such as MySQL. A basic Grails application takes about 500 MB of RAM, so if you are looking for a place to host some demos or your developer portfolio, AppFog is a great way to go. In this Grails Example screencast, you will learn how to package and deploy your application.

To deploy your application, you first need to package it into a Web Application Archive file, also called a WAR file. You do this with the Grails command:

grails war

This will use the production settings in your DataSource.groovy file. The easiest way to work with AppFog is through your terminal and the AppFog Ruby-based commands. If you are using OS X or Linux, your terminal already has Ruby set up. In Windows, you can download a Ruby command environment from rubyinstaller.org. On all three platforms, install the AppFog commands by running:

gem install af

Sign up for a free account on the AppFog website. Then from the yourapp/target directory where your .war file resides:

af login
af push

AppFog will ask you several questions about your app, upload it, and start it. They will provide a unique URL from which you can access your application from anywhere. Follow along with the screencast to see how to deploy your application in the cloud and show it off.

What’s New at Grails Example



New Linux install method
I don’t typically post about updates to our install videos since we try to refresh them several times per year, but the Installing Grails on Linux video has been redone showing how to install Grails using the Groovy Environment Manager (GVM). Traditionally, we have shown the install using the Ubuntu Package Manager, but the Launchpad team has stopped updating their packages beyond Grails 2.2.0, and their current package throws errors when starting the Grails server on Ubuntu 13.x. GVM is a nice tool that let’s you install and switch between several versions of Grails, taking care of all the environment variables for you.

August issue of Grails Academy Magazine
The August issue of our magazine is out and is now viewable on the iPhone as well as iPad. Among the four videos on models, views, controllers, and architecture, is a cool tutorial on how to integrate the Foundation js framework into your views to create forms that support fluid grids and responsive design. The Framework works seamlessly with Grails so you can keep all of your scaffolding in place and just mark up your form elements. Here are all the videos we are featuring this month:

  • Models: Using Where-Clause Queries
  • Views: Creating Fluid Grid Forms
  • Controllers: Calculating Dates – Part 3
  • Architecture: Achieving Code Coverage in Unit Tests

What is Groovy?


Why does Grails use Groovy for its core programming language? Why not just use Java? In this episode of Grails Example, we present a brief slide show that talks about the shortcomings of Java and why Grails needed a groovier language for building web applications.