After being acquired themselves last week, SpringSource has now announced acquiring Cloud Foundry. Currently Cloud Foundry only supports Amazon AWS/EC2 but in the future also VMware vSphere will be supported (surprising isn't it?).
This evening I experimented with Cloud Foundry and have uploaded a simple Grails application to the SpringSource Cloud Foundry Enterprise Java Cloud. I like to share my experiences with this step by step guide.
- Sign up for Cloud Foundry at https://www.cloudfoundry.com/cfapp/reg.html?_flowId=register-flow.
- Sign up for Amazon AWS at http://www.amazon.com/gp/aws/registration/registration-form.html.
- Create an EC2 keypair using the AWS Management Console or ElasticFox FireFox plugin. For detailed info and screenshots check Chris Richardson's blog post about this subject.
- Enable SSH using the AWS Management Console or ElasticFox. See Security Groups section. Again, for more info check Chris Richardson's blog post about this subject.
- Also enable HTTP access on port 80. If you forget this you won't be able to access your application in the cloud. I searched more than a hour for this...
- Change DataSource.groovy:
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
driverClassName = "com.mysql.jdbc.Driver"
username = "book"
password = "book"
url = "jdbc:mysql://${System.getProperty("dbHostName", "localhost")}/book"
}
}
}
Change the username, password and database name (in url property). You will need to enter these credentials in Cloud Foundry later.
The "dbHostName" property is specific for Cloud Foundry as explained in Cloud Foundry Getting Started. - Download the MySQL Connector/J jar and add it to your project's lib folder.
- After changing DataSource.groovy and adding the MySQL jar build a Grails war file using
grails war
. - Login to Cloud Foundry at http://www.cloudfoundry.com/. Don't use IE7! Be warned.
- Navigate to the applications tab and upload you war file. Important things to enter are the application name, the war file to upload, context name and the database section. Leave the rest as is.
- After your application is uploaded it's time to deploy it. Click the application's deploy button. In the next screen just enter a deployment name and leave the rest as is. Now hit the Launch button.
- This will take some time, but it's worth it ;-)
- After lauching your application click to view the deployment details. There is a Go To Home Page link to access your application!
Note: If you are using Google Chrome you won't see the link... That's why my first deployment 'failed' (and a hour gone) as I didn't know how to access it. As IE7 doesn't work either I guess Cloud Foundry only supports FireFox currently (I don't mind about IE, but I would be happy with Chrome).
To be honest Cloud Foundry has some rough edges in terms of documentation and tooling support but at the end I'm very happy how simple it is to deploy a Grails application. No Apache, Tomcat or MySQL setup anymore. This is the future!
Now only pricing should be more affordable. $79,20 p/month (Amazon AWS) for a toy project/application is a little bit high.