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.