Basically Cloudfoundry provide an semi-enclosed platform which allow people to deploy their app. The app has to be supported by Cloudfoundry. At this stage, Cloudfoundry supports langauges and frameworks including Java with Spring, Ruby with rails, Node.js, Scala. And it also supports MySQL, MongoDB, Redis data services. I said semi-enclosed platform because it doesn't give you the freedom as in Amazon EC2. You can't install anything you like as Amazon EC2 does. It's all bounded by what platform can they give. Also, it doesn't have lots of documentation as Amazon does at this stage. All you've got is a simple introduction pdf file and it tells you how to use a command line tool to deploy an app. But what Cloudfoundry provided is still pretty handy and the most important thing is, it's free!
So it's time to get my hands dirty. I've got an application which I am currently developing on. I use Spring, MySQL and other open source tools to create my app.
In order to deploy my application to Cloudfoundry, I need to install "vmc" rubygem. "vmc" is basically a command line tool which allow you to deploy, start, stop, configure your application.
So, to connect to the Cloudfoundry, here is the command:
$ vmc target api.cloudfoundry.com
Succesfully targeted to [http://api.cloudfoundry.com]
$ vmc login
Email: ***@***
password: ***
After login, I can now push (deploy) to Cloudfoundry. The following is interactive process:
Make sure you use the target folder which includes the war file as the pushed location. "vmc" will detect that it's a Java with Spring application (Cool!). I can decide my app name and URL. Also, I need to bind to a MySQL service. It seems I don't need to worry about the username and password which are needed to connect to the MySQL instance. From what I saw, I guess it will interrogate the app context config and change the connection setting before the app starts.
And obviously, I need to include a database initialisation config in my app context file in order to create database once the app starts up. So here is the config:
<jdbc:initialize-database data-source="dataSource">Note: <jdbc:initialize-database> is only avaiable from Spring 3.
<jdbc:script location="classpath:schema-and-reference-data.sql" />
</jdbc:initialize-database>
After a few steps as shown above, my app is up and running. wahoo!
As you can see, deploying app to Cloudfoundry is pretty simple and easy, as long as you know what you are doing. Because of lack of documentation, which I am hoping they improve it any time soon.
All in all, Cloudfoundry is still worthwhile to try (not for production yet) if you want to see how a cloud environment looks like.



No comments:
Post a Comment