Created
July 14, 2014 01:36
-
-
Save buntine/bf9d27ebbacba53e5c32 to your computer and use it in GitHub Desktop.
Rails 4, Capistrano 3.2.1+ local precompilation using rsync
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
# Clear existing task so we can replace it rather than "add" to it. | |
Rake::Task["deploy:compile_assets"].clear | |
desc "Precompile assets locally and then rsync to web servers" | |
task :compile_assets do | |
on roles(:web) do | |
rsync_host = host.to_s | |
run_locally do | |
with rails_env: :production do ## Set your env accordingly. | |
execute :bundle, "exec rake assets:precompile" | |
end | |
execute "rsync -av --delete ./public/assets/ #{fetch(:user)}@#{rsync_host}:#{shared_path}/public/assets/" | |
execute "rm -rf public/assets" | |
# execute "rm -rf tmp/cache/assets" # in case you are not seeing changes | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing this, I've found it very useful.
I've forked the it to precompile the assets only once. The code above would run
assets:precompile
once for each server in role:web
. https://gist.github.com/Jesus/80ef0c8db24c6d3a2745