Sunday, February 10, 2008

Capistrano for Web Site Deployment -- Non Rails

Capistrano is an amazing tool for deploying Rails applications - and like they say when you have a hammer everything looks like a nail...so when I was tasked with developing a way to deploy a simple marketing web site for my company I looked first to Capistrano. I wanted to make it so that non-developers could get set up correctly and then do a "cap deploy" to deploy the current state of the web site. The Capistrano documentation is not great, so I googled around for how I might be able to deploy a non Rails application and found this. That link will lead you to a great blog entry by Pat Nakijima that explains how to deploy a non Rails application with Capistrano. Pat's version of this even sets up the Apache conf file and restarts the apache server using apachectl. I pared down his version because our conf file was going to remain fairly static so I wasn't worried about updating it or restarting Apache for changes to take effect. Also, with the web server hosting many different virtual host I wouldn't want to get stuck if someone had changed any of the conf files and Apache didn't restart correctly...

So here is my minimal version of deploying a simple web site with Capistrano (basically Pat's code with Apache related stuff removed and a micro task that removes the Capfile and config/ directories from the release):