Barefoot Development

Automating Rails deployment without Capistrano

Certainly Capostrano is the most elegant way to deploy your Rails apps, but here's an easy way to automate Rails deployment using just rync and rake. And the best part is that it borrows from a previous blog entry.

This first step is optional, but boy will it make your life easier. Start by setting up public key authentication between your local development machine and your server. We've covered this ground before, so just make sure you're doing it for the account on your server that you'd normally use to FTP to your Rails application.

The second, and final, step: using rync with rake. To see full coverge of this topic (or how to do it if you're developing on a Windows machine, see the HOWTO.

Add the following block to the Rakefile in your local application directory:

desc "Deploy basic application directories"
task :deploy => :environment do
dirs = %w{ app lib test public config}
onserver = "login@remotehost:/home/rails-app-directory/"
dirs.each do | dir|
`rsync -avz -e ssh "#{RAILS_ROOT}/#{dir}" "#{onserver}" --exclude ".svn"`

You'll need to change the onserver line to use your actual username and hostname. Then at the command line, change to your Rails application directory and run:

$ rake deploy

That's it. Enoy your new found productivity.

Sean Brown, Partner, Technology at Barefoot

Labels: , ,


Post a Comment

« Home