Skip to content

Hello World on Cloud Foundry v2

It’s been very busy around here and I’ve been lagging behind on the updates to Cloud Foundry v2. If you’re like me, hopefully you will find this a useful update going from way-old vmc on v1 to cf on v2:

I’m going to create a new account on Cloud Foundry and push my good old bacon pancakes ruby sinatra app to my new account.

Step 1: Create a new account.  Creating a new account on Cloud Foundry, especially with a promo code, is much easier now. No more temporary passwords that were sometimes hard to read.

Go to
Click on the “free trial” button
Enter email address and Promo code (you can use “preshavedyak”)
Check your email and click on the link in the email from Cloud Foundry
Create a password

Now you have an account and password!

Step 2: Update your gems, target, and then log in.

I followed the steps on

$ gem install cf
$ cf target
$ cf login

From the option listed, I chose “1” (development)

Step 3: Push your app. First I was lazy and tried to see if my existing app would push as is.

$ cf push
Name> baconpancakesv2
Memory Limit>256M
Create services for application?>n
Save configurations?>n

Error for the lazy! I got this:

—–> Downloaded app package (4.0K)
/var/vcap/packages/dea_next/buildpacks/lib/buildpack.rb:44:in `build_pack': Unable to detect a supported application type (RuntimeError)
from /var/vcap/packages/dea_next/buildpacks/lib/buildpack.rb:26:in `block in compile_with_timeout’
from /usr/lib/ruby/1.9.1/timeout.rb:68:in `timeout’
from /var/vcap/packages/dea_next/buildpacks/lib/buildpack.rb:25:in `compile_with_timeout’
from /var/vcap/packages/dea_next/buildpacks/lib/buildpack.rb:16:in `block in stage_application’
from /var/vcap/packages/dea_next/buildpacks/lib/buildpack.rb:12:in `chdir’
from /var/vcap/packages/dea_next/buildpacks/lib/buildpack.rb:12:in `stage_application’
from /var/vcap/packages/dea_next/buildpacks/bin/run:10:in `<main>’
Checking status of app ‘baconpancakestest’…Application failed to stage

Step 4: Set up for your ruby sinatra app.

So I decided to read further on

It told me to go to
I followed these steps:

a) $ gem install bundler
b) Create doc “Gemfile” (no extension to the file) and save this text in the file:
source ''

The site says to add the following:
gem ‘nokogiri’
gem ‘rack’, ‘~>1.1′
gem ‘rspec’, :require => ‘spec’

In our case, it is a ruby/sinatra app, so I paste the following in the Gemfile:
source ''
gem 'sinatra'

Save this file in the folder with my baconpancakesv2.rb app

$ bundle install
Skipped $ git add Gemfile Gemfile.lock

Error: I needed to add the ruby version to the Gemfile. In my case, it is ruby ‘1.9.3’
Updated Gemfile to say:
source ''
gem 'sinatra'
ruby '1.9.3'

$ bundle install
This creates the Gemfile.lock file

c) Update the baconpancakes.rb app

I renamed it baconpancakesv2.rb
I followed the steps on
Change the first line of the app:
Delete: require ‘sinatra’
Replace with: class YakApp < Sinatra::Base
and add “end” in the last line

Here is the code for baconpancakesv2.rb:
class YakApp < Sinatra::Base
get '/' do
def youtube_embed(youtube_url)
if youtube_url[/youtu\.be\/([^\?]*)/]
youtube_id = $1
# Regex from #
youtube_id = $5
"<h1>Bacon Pancakes from Cloud Foundry</h1>"+youtube_embed('')

d) Create

Return to
Follow instructions to create file.
Site says:
require ‘./hello_world’

In my case, for our sinatra app, I include the following:
require 'sinatra'
require './baconpancakesv2' (Make sure this is your own directory name)

map ‘/’ do
run YakApp

Also follow the instructions on
So the file will include:
require 'sinatra'
require 'sinatra/base'
require './baconpancakesv2'
map '/' do
run YakApp

Step 5: Try to push the app the right way.

So now you should have a directory that has these 4 files:

  • rb app
  • Gemfile
  • Gemfile.lock

Now do the cf push from that directory. You should be able to push your app to Cloud Foundry. If you used my app, it should look like this:

Of course, this is a limited case. Please consult the Cloud Foundry documentation for further info.

Also check out Andy Piper’s github repo for this same app:

Thanks to Andy for his help!

Step 6: Manage your account in the browser.

Once you have your account. Don’t forget to check out your new account console in the browser. Pretty nice!

Focus on the Code, Leave the Infrastructure to Cloud Foundry

From the Silicon Angle article, Focus on the Code, Leave the Infrastructure to Cloud Foundry

How to create Turntable FM bots on Cloud Foundry, node.js

Cool video by angryrancor and funny at the end ;)

March 5, 2013: Dr. Nic on “Build your own Heroku with open source Cloud Foundry”

March 5, 2013
6:30 pm PST
Location: LinkedIn, 2051 Stierlin Ct, Mountain View, CA

Yak Shaving Hello World! ;)

From the Alameda County (first) Hackathon

Ren & Stimpy Yak Shaving

Barebones Cloud Foundry Youtube Post #2.5 (Ruby)

It’s pretty easy to get started with Cloud Foundry, but here’s also a 10 min barebones version we shared at the Alameda County Hackathon 2012 (record is 7 mins!)

This is a “half project” because I have not changed any of the instructions from the Barebones Hello World in Ruby.

require 'rubygems'
require 'sinatra'

get '/' do

def youtube_embed(youtube_url)

if youtube_url
youtube_id = $1


# Regex from #
youtube_id = $5

<iframe title="YouTube video player" width="560" height="315" src="{ youtube_id }" frameborder="0" allowfullscreen></iframe>}

h1>Bacon Pancakes from Cloud Foundry</h1>"+youtube_embed('')

I just changed the Ruby app code to post a youtube link. You can copy and paste this code into your Ruby app too!

Once this process is complete, copy and paste your new url into a browser (eg. in my case it is
Voila’! Bare bare bones Cloud Foundry app push completed.

(Thanks to for his post on stackoverflow)

NOTE: Yes, this is a very very limited case. If you encounter issues, please consult these resources:

Barebones Cloud Foundry Hello World #2 (using Spring Tool Suite)

It’s pretty easy to get started with Cloud Foundry, but here’s also a 10 min barebones version we shared at JavaOne and will be sharing at Devoxx 2012 (record is 7 mins!)

  1. Sign up! If you do not have a Cloud Foundry account, sign up with this promo code: If using your own laptop, make sure that you have Spring Tool Suite or Eclipse installed: (The instructions below are for STS)
  2. Install the Cloud Foundry plugin, Select Help > Dashboard, Click the Extensions tab, at the bottom left, type in “Cloud” in the Find field, then choose Cloud Foundry and click the Install button. Click on the prompted buttons until you are prompted to restart STS. Restart.
  3. Once you restart STS, in the Servers window where it says “No servers available. Define a new server from the …” click on the “new server wizard” link. (If you don’t see a Servers window, go to Window>Show View>Servers or Other>Servers)
  4. From the list of folders, open VMware, choose Cloud Foundry, and click Next.
  5. You should be in the Account Information page where you will log in to your Cloud Foundry account. If you just created a Cloud Foundry account, check your email for your temporary password.
    If you cannot remember your password, recover it here
  6. Enter your account email address and password and click on the Validate Account button (We recommend copying and pasting both your email (ID) and your password – This is where a lot of people get stuck). Doubleclick on your VMware Cloud Foundry server and make sure
  7. If prompted to create security questions for the new Master Password, follow those steps.
  8. If the center screen in STS is not on the Dashboard, click the Dashboard tab. (If you don’t see it at all, go to Help>Dashboard)
    Under Create in the top left, choose Spring Template Project.
  9. In the Template Selection window, select Spring MVC Project, click Next.
  10. Create a Project Name (eg. my-first-hello) and specify the top-level package (eg. com.mydotcom.hello01).
    Click Finish.
  11. You will now see your new folder listed in the Package Explorer at the left. (If you don’t see Package Explorer, go to Window>Show View>Package Explorer)
    If you seen no alerts or X’s on your package, drag it down and drop into your VMware Cloud Foundry server listed in the bottom left Server window. (If it won’t drop onto the server, delete the app and create a new one).
  12. Once the app window opens, choose Next. For the Deployed URL, you need to create a unique URL prefix (eg. pusheeninspired – no periods or spaces) Click Next, make sure that your memory allocation is at least 512 or 1024, then click Finish and wait for the app to deploy.
  13. Once you see the word “Deployed” next to your app in the Servers list, right click on the app and choose
    Open Home Page to test. Your Hello World sample app should appear. (If you see 404, doublecheck the console to make sure your app has fully deployed. If you see 404 after full deployment, click on your app on the server and increase the memory allocation).
  14. If you want to do something more fun, you can edit your home.jsp file (in app name>src>main>webapp>WEB-INF>views>home.jsp

You can add something like this into your home.jsp file:

<title>Pusheen Inspired</title>
Hello world! Be inspired!
<img src=>
<P>  The time on the server is ${serverTime}. </P>

If you make changes, then save and drag the changed app to the Cloud Foundry server again. If you succeed, you will see something like this:

Voila’! Bare bare bones Cloud Foundry app push completed.

NOTE: Yes, this is a very very limited case. If you encounter issues, please consult these resources:


Get every new post delivered to your Inbox.