Capistrano::Rsync for Capistrano v3
Deploy with Rsync to your server from any local (or remote) repository when using Capistrano. Saves you from having to install Git on your production machine and allows you to customize which files you want to deploy. Also allows you to easily precompile things on your local machine before deploying.
- Works with Capistrano v3 (source
- Suitable for deploying any apps, be it Ruby, Rails, Node.js or others.
- Exclude files from being deployed with Rsync's
- Caches your previously deployed code to speed up deployments ~1337%.
- Works with git and svn.
gem install capistrano-rsync-local
Require it at the top of your
rsync_options to your liking:
set :rsync_options, %w[--recursive --delete --delete-excluded --exclude .git*]
And after setting regular Capistrano options, deploy as usual!
- Clones and updates your repository to
tmp/deploy) on your local machine.
- Checks out the branch set in the
branchvariable (defaults to
rsync_cacheset (defaults to
shared/deploy), rsyncs to that directory on the server.
rsync_cacheset, copies the content of that directory to a new release directory.
nil, rsyncs straight to a new release directory.
After that, Capistrano takes over and runs its usual tasks and symlinking.
Exclude files from being deployed
If you don't want to deploy everything you've committed to your repository, pass
--exclude options to Rsync:
set :rsync_options, %w[ --recursive --delete --delete-excluded --exclude .git* --exclude .svn* --exclude /config/database.yml --exclude /test/*** ]
Precompile assets before deploy
rsync:stage before rsyncing. Hook to that like this:
task :precompile do Dir.chdir fetch(:rsync_stage) do system "rake", "assets:precompile" end end after "rsync:stage", "precompile"
Deploy release without symlinking the current directory
Set Capistrano variables with
set name, value.
|rsync_scm_username||nil||Used for Svn (Optional).|
|rsync_scm_password||nil||Used for Svn (Optional).|
||The path or URL to a SCM repository to clone from.|
||The Git branch to checkout. This is ignored for Svn.|
||Path where to clone your repository for staging, checkouting and rsyncing. Can be both relative or absolute.|
||Path where to cache your repository on the server to avoid rsyncing from scratch each time. Can be both relative or absolute.
||Array of options to pass to
|rsync_local_repo||false||The flag of the local repository, it disables any request to the scm|
|rsync_with_ext||false||Enables checking out an external project|
|repo_ext_url||nil||The URL of the external project. Required if
||Path where to clone the external project.|
Capistrano::Rsync is released under a Lesser GNU Affero General Public License, which in summary means:
- You can use this program for no cost.
- You can use this program for both personal and commercial reasons.
- You do not have to share your own program's code which uses this program.
- You have to share modifications (e.g bug-fixes) you've made to this program.
For more convoluted language, see the