如何减小heroku slug的大小?
我的 slug 大小为 89.5MB,非常大。
然而,存储库的大小非常小:
$ du -hsc
8.0M .
8.0M total
遵循此博客文章:http://dazedthots.blogspot .com/2011/07/reducing-slug-size-heroku.html ,Heroku 上存在更改 Gemfiles 的错误。我的已经改变了好几次,包括 git 依赖项,但现在,唯一的 git 依赖项是“rails_admin”。请参阅下文:
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'
我已联系 Heroku 支持人员,但到目前为止还没有答复?有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
最后,三天后,Heroku 清理了我的缓存。
现在一切都很好,尽管我的 slug 仍然是 54MB,看起来太大了。
Heroku 确认除了联系他们来解决此问题之外没有其他解决方案。希望这个问题能在未来版本的捆绑器中得到解决。
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.
通过在
.slugignore
文件中列出目录,我已经能够在各处削减几兆字节。这可能会帮助您保持在 100mb 限制以下,直到此问题得到解决。您可能还想尝试将更改推送到没有历史记录的新存储库中,因为看起来 Heroku 正在用您所引用的克隆 git 树的完整大小来惩罚您。
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.
由于 Heroku 已经在您引用的帖子中承认了这个问题,所以我会等待并等待,直到 Heroku 解决了这个问题。我想您已经研究过使用 .slugignore 文件减少 slug 大小的其他一些方法?
Slug 大小将包括您所有的 gem,因此您使用的 gem 越多,您的 slug 大小就越大,因为现在每个 Heroku 应用程序都维护自己的 gem。我没有听说过 :git 引用的 gems 使用更多的空间,但我现在已经听说了。
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.
为我解决问题的技巧:
有效的方法:我创建了另一个文件夹。我在该文件夹中搜索 git。我删除了 xml 文件上的文件,然后尝试上传到 Heroku,它成功了。
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.
和你一样,我的 ruby 存储库只是我的 heroku slug 大小的一小部分。我遵循了 这个 Heroku 指南
通过运行以下命令来探索我的heroku dyno上未压缩的slug:
我的大部分空间都被heroku上
/vendors
下的gem源文件占用了。这些源文件不在我的存储库中。我发现了一个 Gemfile 依赖项的 250MB 二进制文件,我正在替换它。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:
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.