Cloud Foundry has been out for a couple years and I’ve been blogging about it for about 18 months (starting here). Cloud Foundry has moved from VMware to Pivotal and continues to undergo rapid development. Although there is a good bit of documentation, it still took me a fair amount of time to get even a basic application running because of changes since my last deployment (and the docs are incomplete). So here is a brief description of how to deploy a trivial Ruby application in the Hosted Developer Environment (I’m on the 60-day free trial period). For the client machine I’m running on a fresh install of Mac OS X version 10.8.4 and using Terminal.

Create and set up the environment:

mkdir ~/cloud ~/cloud/ruby; cd ~/cloud/ruby
sudo gem install bundle sinatra cf

Create three files using your favorite text editor:


source ''
gem 'sinatra'


require 'rubygems'
require 'sinatra'
configure do
    disable :protection
get '/' do
    host = ENV['VCAP_APP_HOST']
    port = ENV['VCAP_APP_PORT']
    "<h1>Hello World!</h1><h2> I am in the Cloud! via: #{host}:#{port}</h2>"
get '/env' do
    res = ''
    ENV.each do |k, v|
        res << "#{k}: #{v}<br/>"


- url:
    memory: 256M
    name: myapp
    instances: 2
    path: .
    command: 'ruby env.rb'

To create a ‘Gemfile.lock’ from the ‘Gemfile’ run the following command:


I can test the application by running the following command:

ruby env.rb

When it tells me that Sinatra has taken the stage I enter http://localhost:4567/ and http://localhost:4567/env in a web browser.

Then I can use ‘cf’ to set my target, login, and push my application to the cloud:

cf target
cf login
cf push

Because we have defined the setup in manifest.yml we don’t have to answer any questions. At this point I can go to and to see the application run.