Getting set up on Bluemix, for Rails developers


I will go step by step, please leave a comment below if anything was missing or if the instructions were incorrect. I’m happy to help.

Bluemix Instructions

  • Install cloudfoundry cli
  • Once finished, type cf -v in your terminal, and you should see something like this: “cf version 6.6.2-0c953cf-2014-10-17T18:10:36+00:00”
  • Note: if you don’t see anything, you might need to open a new terminal tab
  • Type into your terminal: rails new MY_APP_NAME -d=postgresql
  • cd into your new app folder
  • Add rails_12factor gem to gemfile for logging purposes
  • Run bundle in your terminal to install the gem
  • Create a new file manifest.yml in your project root directory, this will store your Bluemix App config
  • Log in to Bluemix
  • Click Create an app
    create an app
  • Choose Ruby on Rails runtime towards the bottom
    choose ruby on rails
  • Choose your app name and route and then click create
  • Click add a service
    add a service
  • Choose ElephantSQL
    elephantsql
  • Rename the service name to elephant and click create
    rename service
  • Update your manifest.yml to look similar to this:
 1 ---
 2 applications:
 3 - name: APP_NAME
 4   memory: 512M
 5   instances: 1
 6   host: HOST_NAME
 7   domain: mybluemix.net
 8   path: .
 9   services:
10   - elephant
  • In your console run rake db:create db:migrate to create your dbs and the schema
  • Open config/database.yml and change your Production settings to look similar to this:
 1 production:
 2 <% if ENV['VCAP_SERVICES'] %>
 3 <% services = JSON.parse(ENV['VCAP_SERVICES'])
 4    postgres = services["elephantsql"]
 5    credentials = postgres.first["credentials"] %>
 6   url: <%= credentials["uri"] %>
 7 <% else %>
 8   <<: *default
 9   database: db/production.sqlite3
10 <% end %>
  • You should now be ready to push to Bluemix
  • Run cf login
  • The API endpoint it’s asking for is: https://api.ng.bluemix.net
  • Choose your target space and org
  • Run cf push -c "rake db:migrate" (NOTE: This may take a moment, and also cause an error at the end)
  • If an error was caused from the previous command, hit ctrl+c to cancel it
  • Next, run cf push -c "null" and you shouldn’t get any errors


blog comments powered by Disqus

Published

25 November 2014

Tags