Ruby

Deployment

Note

See Heroku Buildpack for an alternative way to deploy Ruby on Rails applications.

Using Ruby 1.9.3

The stackato.yml must specify the Ruby runtime version and Rails as the framework type:

framework:
    runtime: ruby19

Default supported ruby version is Ruby 1.8.7.

Known Issues

  • Rmagick gem currently not supported.

  • PostgreSQL Gem (pg) version must be pinned to 0.12.2 (if used):

    gem 'pg', '0.12.2'
  • Must specify Rake Gem immediately before the line loading rails. This happens because when Rails loads, it finds version 0.9.2 of Rake, and that becomes the only version of Rake in the process. Later code wants version 0.9.2.2, and fails:

    gem 'rake', '0.9.2.2'
    gem 'rails'
  • For Ruby 1.9 Cloud Foundry requires a tweak to the jquery-rails gem.

    gem 'cloudfoundry-jquery-rails'

Ruby on Rails 3.1+

To get the asset pipeline working on Stackato, precompile your assets in your development environment, which compiles them into public/assets:

bundle exec rake assets:precompile

Gems and Libraries

A Gemfile must be included in your app that lists all required gems. Run:

$ bundle install
$ bundle package

any time you modify the Gemfile and prior to pushing an app to Stackato.

If VCAP sees a Gemfile.lock in the application, it will ensure the needed gems are packaged, and set the BUNDLE_PATH environment variable to point at them.

Unsupported Gemfile features:

  1. git urls or branch dependencies
  2. gem :path => "some/path"
  3. platform-conditional gems

Database Services

Cloud Foundry supports database auto-reconfiguration for Rails applications.

Worker Applications

Non-HTTP apps that run as a Stackato application under the control of the Health Manager.

To deploy worker applications, you need to use the command key and set the proceses: web key to Null ("~").

Example

name: ruby-app
framework:
    type: rails3
    runtime: ruby19
command: ruby worker.rb
processes:
    web: ~

General Guidelines

App/Web Servers

For the best performance, using Thin Ruby web server is recommended. Include gem 'thin' in your Gemfile.

Bundler

First, you need bundler and rails installed locally. This can be done via:

$ sudo gem install rails bundler --no-ri --no-rdoc

Running rake commands

Generally, bundle exec must be used when running any commands that are installed through Gemfile/bundler.

To run rake stats, for instance, use the stackato run command:

$ stackato run *appname* bundle exec rake stats

See the Command Reference for details on the use of stackato run.

References