Speed up assets:precompile with Rails 3.1/3.2 Capistrano deployment

前端 未结 7 641
野趣味
野趣味 2020-12-04 05:20

My deployments are slow, they take at least 3 minutes. The slow Capistrano task during deploy is assets:precompile. This takes probably 99% of the total deploy time. How can

相关标签:
7条回答
  • 2020-12-04 05:52

    tommasop's solution doesn't work when enabled cached-copy, my modified version:

    task :precompile, :roles => :web, :except => { :no_release => true } do
      from = source.next_revision(current_revision)
      if capture("cd #{shared_path}/cached-copy && git diff #{from}.. --stat | grep 'app/assets' | wc -l").to_i > 0
        run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{Rubber.env} #{asset_env} assets:precompile:primary}
      else
        logger.info "Skipping asset pre-compilation because there were no asset changes"
      end
    end
    
    0 讨论(0)
提交回复
热议问题