Read more

Speed up Capistrano deployments using a remote cached copy of repository

Thomas Eisenbarth
May 02, 2011Software engineer at makandra GmbH

You can seriously speed up deployments with Capistrano when using a local git repository on the server you are deploying to.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Simply add

set :deploy_via, :remote_cache
set :copy_exclude, [ '.git' ]

to your config/deploy.rb and Capistrano will create a clone in shared/cached-copy. This will be updated using git pull when deploying which transfers less bytes and is usually much faster. If deploy_via is set to use default settings (being "export"), Capistrano will do a full clone of the repository from your git host otherwise.

You will notice that this speeds up the deployment but unfortunately keeps the .git directory containing all repository information in each an every release. You can save the bytes by adding set :copy_exclude, [ '.git' ] to exclude this directory when cloning from the local repository.

Posted by Thomas Eisenbarth to makandra dev (2011-05-02 12:05)