Created
March 28, 2014 13:10
-
-
Save giacomomacri/9832331 to your computer and use it in GitHub Desktop.
A workaround for skipping Rails asset pipeline compilation in Capistrano 2 and avoid to compile asset on servers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Comment load 'deploy/assets' in Capfile | |
# Usage | |
# cap deploy -> deploy with asset pipeline compilation | |
# cap deploy -s skip_asset=true -> deploy without asset pipeline compilation, just keep the old asset | |
namespace :deploy do | |
task :default do | |
update | |
# migrate # uncomment this when you need to run migrations | |
assets.precompile | |
restart | |
cleanup | |
end | |
end | |
namespace :assets do | |
desc "Precompile assets locally and then rsync to app servers" | |
task :precompile, :only => { :primary => true } do | |
run "cp -R #{File.join(previous_release, 'public', 'assets')} #{current_path}/public/assets" | |
unless exists?(:skip_asset) | |
run_locally "bundle exec rake assets:clean; bundle exec rake assets:precompile;" | |
servers = find_servers :roles => [:app], :except => { :no_release => true } | |
servers.each do |server| | |
run_locally "rsync -av ./public/assets/ #{user}@#{server}:#{current_path}/public/assets/;" | |
end | |
run_locally "rm -rf public/assets " | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The only problem is that you can't run deploy:migrations it's a workaround! to run migrations just uncomment line 9 and deploy!