Skip to content

Instantly share code, notes, and snippets.

@giacomomacri
Created March 28, 2014 13:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giacomomacri/9832331 to your computer and use it in GitHub Desktop.
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.
# 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
@giacomomacri
Copy link
Author

The only problem is that you can't run deploy:migrations it's a workaround! to run migrations just uncomment line 9 and deploy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment