For a client I needed to set up a sort of staging/development instance. We're a distributed team and in order for us to review each others' work before it's deployed, we need to host it somewhere that's not the production server.
Apparently there's a Capistrano extension for handling this, and there's some good, well-cited documentation out there as well, but it all felt really heavy weight until I found this article.
I love the simplest, most elegant solution, and this approach wins. Now deploying the staging version (off the git staging branch) is as simple as cap staging deploy
. If I want the main production branch, I cap production deploy
, and I can easily add another branch if I wish. The code (from deploy.rb
):
task :production do role :app, "192.168.100.1" role :web, "192.168.100.1" role :db, "192.168.100.1", :primary => true set :branch, "master" end task :staging do role :app, "192.168.100.2" role :web, "192.168.100.2" role :db, "192.168.100.2", :primary => true set :branch, "staging" end
cap staging deploy:migrations
, cap production mongrel:cluster:start
, etc. all work as expected, and even better yet, if I fall into my old habits of cap deploy
I'll get an error which reminds me that I have to specify a deploy target.
Who needs complex capistrano extensions when you have this? I don't think it can get cleaner or simpler!