Deploy your first RoR App at AppFog


In all of free PAASs, I will personally recommend Appfog because of its web based management interface. Basically AppFog  is a polyglot platform powered by Cloud Foundry. The AppFog free plan comes up with 2 GB Ram , 100 MB DB (temporary and it’s increasing) and multiple runtimes. I think, it’s enough for deploying your first pet or side project. Recently, I deployed a RoR (Ruby on Rails) application at AppFog. It’s quite straight forward. So, now I am going to share my experience of deploying the application step by step.

I developed my RoR application in my local/development environment and push it to AppFog by using af gem.  Create a free account and setting up  RoR application  with MySql  DB.  I set up a RoR application named: rain_test_app.  I used MySql here, Because it’s easy and AppFog automatically recognizes MySql.

I had already sai1d that I  used the af gem. Basically, af gem is a tool to push source code to Appfog and deploy it. Expecting that you are using  rvm, rbenv or others Ruby/Gem management system. So, now open your terminal and install af gem.

gem install af

If your installation is done, then I will show a message as below one..
Successfully installed af-
So, af gem installation is done. Now, login with Appfog credentials.  Open terminal and type..

af login

It will prompt for AppFog username (email address) and password.I went to the application’s (the RoR app that I created in my local/development environment) root and pushed to AppFog. But before pushing it to PAAS, I pre-compiled the assets in my local/development environment. Oh, I forgot to mention that  I created my RoR app with the versions of Rails 3.2.3 and Ruby 1.9.3p125.  Just to let   know that , Rails 3 supports asset pipeline. It compiles them into public assets, so that you can tweak the productionserver later on. So,  I needed to Pre-package the app first.

bundle package
bundle install

And then, in  config/environments/production.rb file, Set it to

config.server_static_assets = true
config.assets.compress      = true

If you use twitter bootstrap in your application, the add follow line as weell
config.assets.precompile += %w(bootstrap.min.css)

Pre-compiled the assets.. Ran this command in terminal ..

bundle exec rake assets:precompile

Now, pushed and deployed the app,

af push  rain_test_app

In case,  it doesn’t work properly. Then you can check and trace the error. Just Run the following command.

af logs rain_test_app --all

Finally, It gave me a message: Push Status: OK. Seems that deploying was done. No it was not done. Still the db migrations were left and I had to do other db configurations. AppFog doesn’t support any direct access to database.  So, interactng with your database, You will have to install another gem called caldecott which creates a tunnel that connects a port on your local computer to the service in AppFog. Type following line in terminal..

gem install caldecott

By the tunnel command, I accessed the MySql db and ran all console commands in AppFog. After that, I took the DB credentials from AppFog and then configured the production’s DB environment in my application.  First, I checked out  that the service was available for me in AppFog.

af services

It will show up  all available services and Databases. I chose my one..

af tunnel raintestapp-mysql-16743

It returned the db credentials.

Service connection info:
username  : up9aKxigrR5Am
password  : p34rlXo2kDxkW
name      : d7fcafced333c42b19aefdb21da29dbb0
infra     : ap-aws

I updated the above credentials in database.yml at production environment as below..

adapter  : mysql2
database : d7fcafced333c42b19aefdb21da29dbb0
username : up9aKxigrR5Am
password : p34rlXo2kDxkW
port     : 10000
host     :

Saved and updated it to AppFog.

af update rain_test_app

If you deploying is successful and it will give some Okay statuses. You can also access the mysql server by af turnel. Finally, I migrated the db in AppFog.  To migrate the db, I ran following comands..

RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake db:seed

Yes, my db database is sync with my local one.
It’s done.  visit the link provied by AppFog.


Eftakhairul Islam

Hi, I'm Eftakhairul Islam, a passionate Software Engineer, Hacker and Open Source Enthusiast. I enjoy writing about technical things, work in a couple of startup as a technical advisor and in my spare time, I contribute a lot of open source projects.


6 thoughts on “Deploy your first RoR App at AppFog

  1. Thanks for this, it was very helpful. Where did you run the last 2 commands from though?

    RAILS_ENV=production rake db:migrate
    RAILS_ENV=production rake db:seed

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Read previous post:
LEMP On Fedora 17 with setting up virtual host

Courtesy: Linux, Nginx, MySQL, PHP knows as “LEMP” server. Here, Nginx  is very fast and lightweight web server which is...