Grails Plugin for Cloud Foundry
In my blog ‘Grails + SQLFire + MySQL: Deploying to Cloud Foundry’ I described the installation and usage of the Cloud Foundry command line tool ‘VMC’. VMC is a great tool however I recently discovered a Grails Cloud Foundry plugin that allows me to execute Cloud Foundry commands from within the Grails console.
To install the Grails Cloud Foundry plugin simply do:
The Grails Cloud Foundry plugin looks for login credentials in Config.groovy. To configure the credentials, open Config.grooy and add the following properties:
Creating a Cloud Foundry Services
I am going to use the application from “Grails + RabbitMQ: Sending a JSON Message”. This application needs both RabbitMQ and MySQL. To achieve this, the first thing we need to do is create instances of both RabbitMQ and MySQL service against your account account.
Open the Grails console and execute:
cf-create-service rabbitmq rabbitmq
cf-create-service mysql mysql
Pushing to Cloud Foundry
Lets attempt to push the example project “Grails + RabbitMQ: Sending a JSON Message” to Cloud Foundry. Open the Grails console within your example project and execute:
This command packages up your application and kicks off the process of uploading you application to Cloud Foundry. As part of the process, the command is going to ask you a series of simple questions:
Q1: You running in development …etc? - Basically Grails is asking if it should build the war.
Q2: Application Deployment URL?
A: Enter the URL you would like to deploy this application on.
Q3: Would you like to bind ‘mysql’?
Q4: Would you like to bind ‘rabbitmq’?
It really is that simple.
Open a web browser and hit the URL you entered during the push process.