0ko96g
Last Updated: February 25, 2016
·
2.755K
· gregmolnar
5319381fac0e775e5b2168650aae1e01

Capistrano task for deploy compiled assets

If you deploy to an Amazon VPS with capistrano you might find the assets compilation time too long. In some cases it is faster to compile the assets locally but it is not a good practice to commit the compiled assets into the repo and capistrano deploys from that. Here is a workaround for this:

  namespace :assets do
    desc "compile assets locally and upload before finalize_update"
    task :deploy do
        %x[bundle exec rake assets:clean && bundle exec rake assets:precompile]
        ENV['COMMAND'] = " mkdir '#{release_path}/public/assets'"
        invoke
        upload '/path/to/app/public/assets', "#{release_path}/public/assets", {:recursive => true}
    end
end
after "deploy:finalize_update", "assets:deploy"
Say Thanks
Respond