Skip to content

Instantly share code, notes, and snippets.

@mirakui
Created November 15, 2012 13:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirakui/4078624 to your computer and use it in GitHub Desktop.
Save mirakui/4078624 to your computer and use it in GitHub Desktop.
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