Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fast deploy using capistrano_rsync_with_remote_cache and turbo-sprockets-rails3
# Requirements:
# https://github.com/vigetlabs/capistrano_rsync_with_remote_cache
# https://github.com/ndbroadbent/turbo-sprockets-rails3
require 'capistrano/recipes/deploy/strategy/rsync_with_remote_cache'
Capistrano::Deploy::Strategy::RsyncWithRemoteCache.class_eval do
def deploy!
update_local_cache
prepare_assets
update_remote_cache
finalize_assets
copy_remote_cache
end
def prepare_assets
system([
"test ! -d #{assets_cache} && mkdir -p #{assets_cache}",
"mv #{assets_cache} #{assets_path}",
"cd #{local_cache_path}",
"RAILS_ENV=#{configuration[:rails_env]} bundle exec rake assets:precompile"
].join(';'))
end
def finalize_assets
system("mv #{assets_path} #{assets_cache}")
end
def assets_cache
File.expand_path(configuration[:assets_cache] || '.assets_cache')
end
def assets_path
File.expand_path(File.join(local_cache_path, configuration[:assets_path] || 'public/assets'))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.