Created
March 13, 2016 18:30
-
-
Save krists/bdb5dc9609030604ca07 to your computer and use it in GitHub Desktop.
Compile Rails assets locally and rsync them to server (Capistrano 3)
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
# lib/capistrano/tasks/assets.rake | |
namespace :assets do | |
desc "Precompile assets locally and then rsync to web servers" | |
task :precompile do | |
on roles(:web) do | |
rsync_host = host.to_s | |
run_locally do | |
with rails_env: fetch(:stage) do | |
execute :bundle, "exec rake assets:precompile" | |
end | |
execute "rsync -vrhe ssh --progress --delete ./public/assets/ #{fetch(:user)}@#{rsync_host}:#{shared_path}/public/assets/" | |
execute "rm -rf public/assets" | |
execute "rm -rf tmp/cache/assets" | |
end | |
end | |
end | |
end | |
namespace :deploy do | |
after :updated, "assets:precompile" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment