Last active
December 21, 2015 11:59
-
-
Save tiagoamaro/6303123 to your computer and use it in GitHub Desktop.
Capistrano task for compiling tasks locally
This file contains 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
# UPDATE: This will only work for Capistrano 2.x and probably will not work for Capistrano 3. | |
# | |
# This Gist was based on fernando blat post: (http://fernando.blat.es/post/12563486374/optimize-deploy-time-compiling-your-assets-locally) | |
set :rails_env, 'production' | |
namespace :assets do | |
desc 'Run the precompile task locally and rsync with shared' | |
task :precompile do | |
run_locally('rm -rf public/assets/*') | |
run_locally("RAILS_ENV=#{rails_env} rake assets:precompile") | |
run_locally('touch assets.tgz && rm assets.tgz') | |
run_locally('tar zcvf assets.tgz public/assets/') | |
run_locally('mv assets.tgz public/assets/') | |
end | |
desc 'Upload precompiled assets' | |
task :upload_assets do | |
upload "public/assets/assets.tgz", "#{release_path}/assets.tgz" | |
run "cd #{release_path}; tar zxvf assets.tgz; rm assets.tgz" | |
end | |
end | |
before 'deploy:update_code', 'assets:precompile' | |
after 'deploy:create_symlink', 'assets:upload_assets' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment