The Rails deployment story has improved dramatically since the early days, but it can still be challenging. Compiling assets, running migrations, achieving zero-downtime deployments, and load balancing your application servers are some of the tasks that you’ll want to handle as part of your deployment strategy. Many deployment processes still tend to be a mixture of automation and manual work. The goal is to have a fully automated, repeatable and fast deployment process. Sounds simple on paper, but as many of us already know, this process is time consuming, error prone and has the tendency to make you want to rip your hair out or throw your keyboard out the window.
For those of us not using Heroku, Capistrano is a de facto standard when it comes to deploying Rails applications. Capistrano version 3 was released a little over a year ago and is substantially different than version 2. For one, Capistrano is no longer a monolithic framework designed for just deploying Rails applications. It uses a more modular design and is intended to be framework agnostic. It should be possible to use Capistrano to deploy a NodeJS or Clojure application, for example. Much of the Rails specific tasks have been broken out into separate gems. In addition, there is a growing ecosystem of plugins that can be included to perform specific tasks. Using these plugins can save you lots of time and effort when it comes to creating your deployment solution.
capistrano-rails provides tasks that you are going to need on just about every Rails application. It includes tasks to set your environment, manage your assets, and run (or not run) your migrations.
capistrano-bundler. Just like it sounds - this plugin will run
bundle install as part of the Capistrano deployment flow. You can also use the standalone task to install your gems on an ad-hoc basis. There are a number of ways to configure the bundling process such as the ability to parallelize your gem installs.
capistrano-rbenv. This is a core plugin that is going to configure Capistrano to use the correct, rbenv version of ruby when running your deployment. Take a look at capistrano-rvm or capistrano-chruby if you use one of those version managers instead.
capistrano-unicorn-nginx. If you use unicorn behind nginx to serve your Rails application, you might want to take a look at this. It can help you configure single node or clustered unicorn deployments. It supports zero-downtime deployments and provides some basic server management capabilities such as the ability to restart unicorn. You can also look at capistrano3-unicorn for an alternative option.
capistrano-postgresql allows you to automate some of the typical administration tasks you will need to perform to set up Rails with Postgresql. For example, you can use it to create your database and database user. It can also generate a populated database.yml with the correct information. Since populating database.yml is a step that is often not automated at all, this is can be pretty powerful.
capistrano-faster-assets. Speed up your deployments by only compiling assets when needed.
capistrano-pending. Feeling nostalgic? This restores the old version 2 task which allows you to see the commits (or a diff) between what is on the server and what is about to be deployed.
capistrano-ssh-doctor. Having trouble connecting to your servers over SSH? This interesting plugin does not actually affect your deployments in any way. Rather, it is a diagnostic tool to help you troubleshoot problems with your SSH connection to the servers you are deploying to.
Did I miss anything? What plugins or other techniques are you using in your Capistrano deployments?