Skip to content

Instantly share code, notes, and snippets.

@jarthod

jarthod/deploy.rb

Created Sep 20, 2015
Embed
What would you like to do?
Capistrano local assets compile
# Rewrite precompile tasks to do it locally
Rake::Task["deploy:compile_assets"].clear
task :compile_assets => [:set_rails_env] do
# invoke 'deploy:assets:precompile'
invoke 'deploy:assets:precompile_local'
invoke 'deploy:assets:backup_manifest'
end
namespace :assets do
task :precompile_local do
# compile assets locally
run_locally do
execute "RAILS_ENV=#{fetch(:stage)} bin/rake assets:precompile"
end
# rsync to each server
local_dir = "./public/assets/"
on(roles :web) do
remote_dir = "#{host.user}@#{host.hostname}:#{release_path}/public/assets/"
run_locally { execute "rsync -av #{local_dir} #{remote_dir}" }
end
# clean up
run_locally { execute "rm -rf #{local_dir}" }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment