Hack: Deploying with git

This has been updated, see: Hack: Deploying with git and rake-remote_remote

Add the following to your Rakefile

ENV['PRODUCTION_HOST'] ||= "www.yourhost.com"
task :deploy do
  system("ssh #{PRODUCTION_HOST} 'set -x; cd /path/to/app/install && git pull && bundle'")
end

desc "restart production" 
task :restart do
  system("ssh #{PRODUCTION_HOST} 'set -x; cd /path/to/app/install && RACK_ENV=#{ENV['RACK_ENV']} bundle exec rake unicorn:restart --trace'")
end

Then run

$ RACK_ENV=production PRODUCTION_HOST=www.foohost.com bundle exec rake deploy restart

or just

$ RACK_ENV=production PRODUCTION_HOST=www.foohost.com bundle exec rake deploy

Note -- This assumes the following:

  • You've checked out your repo on your remote host.
  • You've setup your app and it's running on your remote server.
  • You're using using Unicorn.
  • You're using Bundler.