Friday, April 13, 2012

Deploying Grails app to CloudFoundry

http://grails.org/plugin/cloud-foundry
http://blog.springsource.com/2011/04/12/one-step-deployment-with-grails-and-cloud-foundry/
http://docs.cloudfoundry.com/tools/vmc/installing-vmc.html
http://grails-plugins.github.com/grails-cloud-foundry/docs/manual/index.html

  • grails install-app cloud-foundry
  • Create /<homedir>/.grails/settings.groovy:
    •     grails.plugin.cloudfoundry.username = "<email>"
    •     grails.plugin.cloudfoundry.password = "<passwd>"
  • grails cf-info
    • VMware's Cloud Application Platform
      For support visit http://support.cloudfoundry.com
      Target:   http://api.cloudfoundry.com (v0.999)
      User:     <email>
      Usage:    Memory   (1.0G of 2.0G total)
                Services (1 of 16 total)
                Apps     (2 of 20 total)
  • grails prod cf-push
    • choose app name
    • say yes to MySQL
    • say no to postresql
  • grails cf-services
    • ============== System Services ==============
      +------------+---------+---------------------------------------+
      | Service    | Version | Description                           |
      +------------+---------+---------------------------------------+
      | mysql      | 5.1     | MySQL database service                |
      | postgresql | 9.0     | PostgreSQL database service (vFabric) |
      | mongodb    | 1.8     | MongoDB NoSQL store                   |
      | redis      | 2.2     | Redis key-value store service         |
      | rabbitmq   | 2.4     | RabbitMQ message queue                |
      +------------+---------+---------------------------------------+
      =========== Provisioned Services ============
      +---------------+---------+
      | Name          | Service |
      +---------------+---------+
      | mysql-f9bee59 | mysql   |
      +---------------+---------+
  • grails cf-apps
    • +-------------------------+----+---------+------------------------------------------+---------------+
      | Application             | #  | Health  | URLs                                     | Services      |
      +-------------------------+----+---------+------------------------------------------+---------------+
      | blog                    | 1  | RUNNING | gailsblog.cloudfoundry.com               | mysql-f9bee59 |
      +-------------------------+----+---------+------------------------------------------+---------------+
      | cloudfoundry_grailsblog | 1  | RUNNING | cloudfoundry_grailsblog.cloudfoundry.com |               |
      +-------------------------+----+---------+------------------------------------------+---------------+
  • grails cf-map grailsblog.cloudfoundry.com
  • cf-apps
    • +-------------------------+----+---------+---------------------------------------------------------+---------------+
      | Application             | #  | Health  | URLs                                                    | Services      |
      +-------------------------+----+---------+---------------------------------------------------------+---------------+
      | blog                    | 1  | RUNNING | gailsblog.cloudfoundry.com, grailsblog.cloudfoundry.com | mysql-f9bee59 |
      +-------------------------+----+---------+---------------------------------------------------------+---------------+
      | cloudfoundry_grailsblog | 1  | RUNNING | cloudfoundry_grailsblog.cloudfoundry.com                |               |
      +-------------------------+----+---------+---------------------------------------------------------+---------------+
  • grails cf-unmap gailsapp.cloudfoundry.com
  • grails cf-update-instances 3
    • Scaled 'blog' up to 3 instances.
  • grails prod cf-update
    • Updating Application:  Checking for available resources: OK  Processing resources: OK  Packing application: OK  Uploading (28K): OK
      Application 'blog' stopped.
      Trying to start Application: 'blog'.
      ...Application 'blog' started at http://grailsblog.cloudfoundry.com
  • grails cf-delete-app