Thomas Mullaly

DevOps, Security and IT Leadership

Rails Deployment Using Capistrano

Create your new rails project

rails new myapp
cd myapp

Get git initialized

git init

Edit your .gitignore file to include some more options

vi .gitignore

Add this:

# Added from https://github.com/github/gitignore/blob/master/Rails.gitignore
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
/.bundle
/vendor/bundle
/log/*
/tmp/*
/db/*.sqlite3
/public/system/*
/coverage/
/spec/tmp/*
**.orig
rerun.txt
pickle-email-*.html

Now add the files to git and commit

git add .
git commit -a -m 'initial commit'

Edit your Gemfile and uncomment capistrano then run:

bundle install

Now we’re gonna “capify” the application, run:

capify .

You should see this output:

[add] writing './Capfile'
[add] writing './config/deploy.rb'
[done] capified!

Capistrano logs into your production servers and checks out the latest version of your production branch, we need to get our app onto a scm server that the production server has access to. I’m going to use bitbucket.org as the example, but it could be anywhere.

git remote add origin https://bitbucket.org/my-user-name/myapp.git
git push origin master