Clone me on Cloud Foundry

Ruby Apps on Cloud Foundry

About Jennifer

Contact Info

Twitter : @jencompgeek

Email: jhickey@vmware.com

About Cloud Foundry

main

Open Source

main

Cloud Foundry Service

main

Getting Your Hands Dirty

Getting Started

main

Signup Promo Code

CFOpenTour2012

Assumptions for Demos

You have RVM installed

You have Ruby 1.9.2 available

Tour Cloud Foundry via VMC

VMC Basics

Install the CLI for Cloud Foundry called VMC. Its packaged as a Ruby gem.

sudo gem install vmc --pre

Log into cloudfoundry.com or any other cloudfoundry instance

vmc target api.cloudfoundry.com
vmc login [username]

Push the code to the cloud

vmc push

Ruby Support

VMC is a gem

VMC can be used by any Ruby Application

VMC commands work against any Cloud Foundry instance

Gemfile

source "http://rubygems.org"

gem "sinatra"
gem "shotgun"
gem "json", "~> 1.4.6", :require => "json/pure"
gem "haml"
gem "vmc", "~> 0.3.16.beta.6"

gem "vmc"

Using VMC from Sinatra

At the top of your app.rb include require "vmc/client"

You can then use VMC::Client

Example

get "/apps" do
    @vmcclient = VMC::Client.new(@target, @token)
    @apps = @vmcclient.apps
    haml :apps
end

Packaging Ruby Apps

Use Bundler

Cloud Foundry manages your dependencies using your Gemfile.lock

Run bundle package before deploying to Cloud Foundry

Gems downloaded from rubygems.org are cached across CF

Gems are installed into repository local to your app

Ruby Web Frameworks

Sinatra

Rails

Rack

Sinatra Demo

Summer Jobs

Auto Reconfiguration

If you prefer to DIY

Create config/cloudfoundry.yml with

autoconfig: false

Use cf-runtime gem to make service connections or parse environment

Service tunneling

To install

gem install caldecott

To connect

vmc tunnel <service_name>

Make sure you are using addressable 2.2.6

Manifest

Manifest Example

.:
name: hello-sinatra
instances: 1
framework:
  name: sinatra
  info:
    exec: ruby main.rb
    description: Sinatra Application
    mem: 128M
url: ${name}-suraci.${target-base}
services:
  mysql-2cccd:
    type: :mysql
mem: 128M

Rails Demo

Website Prelaunch

Rails Console

Example

vmc rails-console mynewblog
irb():001:0> @comment = Comment.find_by_author("Joe")
#<Comment id: 7, post_id: 1, author: "Joe", body: "I have something real...">
irb():002:0> @comment.delete
#<Comment id: 7, post_id: 1, author: "Joe", body: "I have something real...">
irb():004:0> exit

Standalone applications 

Brand New to cloudfoundry.com

The “no framework” option

Supports long-running apps

Great for background or asynchronous jobs

Requires vmc 0.3.16.beta.6 or higher

Demo Resque

Problems with Monolithic Applications

Lack of scalability

Lack of deployability

More Problems with Monolithic Applications

Applications are brittle

Monolingual

Standalone applications to the rescue!

Summary of what we did

Got up and running on VMC

Deployed and edited Sinatra app

Deployed Rails app with MySQL service

Used Rails Console

Saw Redis and Resque in action with Standalone Apps

Coming soon?

Ruby 1.9.3

Remote debugging for local cloud

IRB console for other types of Ruby apps

Rails improvements

Bundler/Gem improvements

Help us make Ruby better on Cloud Foundry

Open source code

Ideas, issues

Sign-up for a free account

Samples

Sinatra Summer Jobs

Rails Website Prelaunch

Resque

Questions ?

PDF Printable Version | Preso List | Fork me on GitHub | /

#