Setting up a Grails app on Cloud Foundry

I was lucky enough to get access to cloud foundry. I have heard a lot about how easy it is to deploy a grails app on cloudfoundry. I had to try it myself and here is my experience trying to do so….

Building An App
Lets just create a simple grails app called “HelloCloudFoundry”. to do so, we can create a grails app by running the “grails create-app” command like follows:

   /home/manijshrestha/workspace/$grails create-app HelloCloudFoundry

Once the app is created lets just dummy up a index.gsp, I usally delete the default one grails creates and replace it with my own with body text “HelloWorld”. For this example I replaced the content of the index.gsp with simple html as follows

        <title>Hello Cloud Foundry</title>
        Hello From the Cloud!

Installing cloud foundry plugin
I was pretty impressed that grails already had a cloupowershellpowershelld foundry plugin, to install lets just run our typical grails install as follows

/home/manijshrestha/workspace/HelloCloudFoundry$ grails install-plugin cloud-foundry 

Now, it should install the plugin for cloudfoundry

Configuring the App
To set up the app its fairly easy, edit the Config.grooy file found in grails-app/conf/Config.groovy
and set up with your credentials. If you don’t have an account get one via
You should receive an email with user username and password

grails.plugin.cloudfoundry.username = ''
grails.plugin.cloudfoundry.password = 's3kr3t'
grails.plugin.cloudfoundry.appname = 'YOUR-APP-NAME'

thats it!!! we about 90 percent done!

Now, lets deploy our app!!! Yes we are there now..

Now lets just run a grails command to push the app to the cloud foundry

from the command line run

NOTE: technically, we should configure our database like mysql or mongodb etc, but for our demo we will just push it, the command will asks us to create one and we will do so.

   $grails prod cf-push

You will see some input dialogs asking you for the app url? and also since, we didn’t configure a service it will ask you if you would like to bind a mysql service, See my responses below:

Application Deployed URL: ''?

Would you like to bind the 'mysql-XXXX' service? ([y], n)

And BOOM we are done now you can navigate to your application URL
in my case its

Hopefully you enjoyed this, feel free to comment!

Helpful Links:

6 thoughts on “Setting up a Grails app on Cloud Foundry

  1. Application Deployed URL: ‘’?

    Would you like to bind the ‘mysql-7153’ service? ([y], n)

    Would you like to bind the ‘env-postgresql’ service? ([y], n)

    Creating application ServiceDesk at with 512MB and services [mysql-7153]: OK

    Uploading Application:
    Checking for available resources: OK
    Processing resources: OK
    Packing application: OK
    Uploading (22M):
    Error: 504 Gateway Time-out

    org.springframework.web.client.HttpServerErrorException: 504 Gateway Time-out
    at org.cloudfoundry.client.lib.CloudFoundryClient$ErrorHandler.handleError(
    at org.cloudfoundry.client.lib.CloudFoundryClient.uploadApplication(
    at ClientWrapper.methodMissing(_CfCommon_groovy:491)
    at CfPush$_run_closure1_closure4.doCall(CfPush:114)
    at _CfCommon_groovy$_run_closure5.doCall(_CfCommon_groovy:119)
    at CfPush$_run_closure1.doCall(CfPush:39)

    Any Solution is gratly appriciated.

    1. Hi Hardik, looks like cloud foundry might be having internal issue at the time. I would try again and see if that would resolve it. Let me know if it persists.

      1. hello manijshrestha,
        I have tried again but still i got same error.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s