How to reduce heroku slug size?
My slug size is 89.5MB which is huge.
However the repository开发者_如何学C 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?
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.
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.
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.
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.
As with you, my ruby repo was only a fraction of my heroku slug size. I followed the advice of this heroku guide to explore the uncompressed slug on my heroku dyno by running:
$ heroku run bash -a [app-name]
Most of my space was taken up by the gem source files under /vendors
on heroku. These source files are not in my repo. I found a single 250MB binary file for a Gemfile dependency which I am in the process of replacing.
精彩评论