带有大量小咖啡脚本文件的Ruby on Rails 3.2需要花费大量时间进行部署:
有没有办法加速Heroku上的资产编译?
Compiled backbone/apps/manage_promote/show/templates/_integrate.js (271ms) (pid 7108)
Compiled backbone/apps/manage_promote/show/templates/show_layout.js (336ms) (pid 7108)
Compiled backbone/apps/manage_promotions/list/list_controller.js (260ms) (pid 7108)
Compiled backbone/apps/manage_promotions/list/list_view.js (236ms) (pid 7108)
Compiled backbone/apps/manage_promotions/list/templates/_empty.js (335ms) (pid 7108)
Compiled backbone/apps/manage_promotions/list/templates/_promotion.js (380ms) (pid 7108)
Compiled backbone/apps/manage_promotions/list/templates/_promotions.js (368ms) (pid 7108)
Compiled backbone/apps/manage_promotions/list/templates/list_layout.js (284ms) (pid 7108)
Compiled backbone/apps/manage_promotions/manage_promotions_app.js (238ms) (pid 7108)
Compiled backbone/apps/manage_promotions/new_edit/new_edit_controller.js (267ms) (pid 7108)
Compiled backbone/apps/manage_promotions/new_edit/new_edit_view.js (241ms) (pid 7108)
Compiled backbone/apps/manage_promotions/new_edit/templates/new_edit_layout.js (301ms) (pid 7108)
Compiled backbone/apps/manage_statistics/list/list_controller.js (264ms) (pid 7108)
Compiled backbone/apps/manage_statistics/list/list_view.js (231ms) (pid 7108)
答案 0 :(得分:0)
选项1:本地预编译资产
您可以在本地编译资源,将它们添加到源代码管理并将它们推送到Heroku:
RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets
git commit -m "Precompile assets"
Heroku将检测预编译的资产并跳过编译
-----> Preparing Rails asset pipeline
Detected manifest.yml, assuming assets were compiled locally
有关其他信息,请参阅https://devcenter.heroku.com/articles/rails-asset-pipeline#the-rails-3-asset-pipeline
选项2:对链轮使用memcache缓存
通过http://blog.alexmaccaw.com/faster-deploys(免责声明:我没有尝试过这种方法。)
启用内存缓存附加组件
heroku addons:add memcachier
将dalli
和memcachier
添加到您的Gemfile中。
在config/environments/production.rb
config.assets.cache_store = :dalli_store