How to reduce heroku slug size?

為{幸葍}努か 提交于 2019-12-10 02:20:36

问题


My slug size is 89.5MB which is huge.

However the repository size is quite small:

$ du -hsc 
8.0M    . 
8.0M    total

Following this blog post: http://dazedthots.blogspot.com/2011/07/reducing-slug-size-heroku.html , there is a bug on Heroku with changing Gemfiles. Mine has changed several times including git dependencies but now, the only git dependency is "rails_admin". See below:

source 'http://rubygems.org'

gem 'rails',      '~> 3.1.0'
gem 'rails-i18n', '~> 0.1.3'
gem 'pg',         '~> 0.11.0'
gem 'rake',       '~> 0.8.7'
gem 'thin', '~> 1.2.11'
gem 'heroku', '~> 2.4.0'
gem 'squeel',     '~> 0.8.6'
gem 'devise', '~> 1.4.2'
gem 'slim-rails',  '~> 0.2.0'
gem 'simple_form', '~> 1.4.2'
gem 'will_paginate', '~> 3.0'
gem 'sunspot_rails', '~> 1.2.1'
gem 'jquery-rails',    '~> 1.0.12'
gem 'modernizr-rails', '~> 2.0.6'
gem 'rails_admin', git: 'https://github.com/sferik/rails_admin.git'
gem 'sass-rails',   '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier',     '~> 1.0.0'
gem 'newrelic_rpm'

I've contacted the Heroku support but no answer until now? Any idea?


回答1:


Finally, after 3 days, Heroku cleaned up my cache. Everything is fine now though my slug is still 54MB which seems too big.

Heroku confirmed there was no other solution than contacting them to resolve this issue. Hopefully, it will be resolved in a future version of bundler.




回答2:


I've been able to trim a few megabytes here and there by listing directories in the .slugignore file. That may help you stay under the 100mb limit until this issue gets resolved.

You may also want to experiment with pushing your changes into a new repository without history, since it looks like Heroku is penalizing you with the full size of the cloned git tree that you are referencing.




回答3:


Being as Heroku have acknowledged the problem in the post you have referenced I would wait and sit it out until Heroku have fixed it their end. I take it you've already looked into some of the other ways to reduce a slug size with a .slugignore file?

Slug size will include all your gems so the more gems you use the larger your slug size will be since each Heroku app maintains it's own gems these days. I'd not heard of :git referenced gems using more space but I have now though.




回答4:


THE TRICK THAT FIXED THE PROBLEM FOR ME:

What works: I made another folder. I search for git in that folder. and I delete the files on the xml file and then I tried uploading to Heroku and it worked.



来源:https://stackoverflow.com/questions/7256069/how-to-reduce-heroku-slug-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!