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

前端 未结 7 731
野趣味
野趣味 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:51

    There are times when I need to force skip asset precompile when deploying a fix asap. I use the following hack as a complement to other answers to do the job.

    callback = callbacks[:after].find{|c| c.source == "deploy:assets:precompile" }
    callbacks[:after].delete(callback)
    after 'deploy:update_code', 'deploy:assets:precompile' unless fetch(:skip_assets, false)
    

    This script will change the built-in asset-precompile hooking, so it will be called based on the skip_assets parameter. I can call cap deploy -S skip_assets=true to skip asset precompile completely.

提交回复
热议问题