减少 Heroku 编译的 Slug 大小
我刚刚将我的应用程序上的 bare-ree-1.8.7 堆栈下的 Rails 更新到 v2.3.6,编译后的 slug 大小已增长至 40.5Mb!在最后一次 git 推送之前,slug 大小约为 20Mb,并且使用 Rails v2.3.5。
是因为我的 slug 安装了两个 Rails 版本吗?可能我遗漏了一些东西,但我没有在我的应用程序中添加任何特殊的代码/文件来将 slug 大小增加约 20Mb。
你能告诉我如何减少段头的大小吗?
任何帮助将不胜感激。
预先非常感谢您。
I've just updated rails to v2.3.6 on my app under a bamboo-ree-1.8.7 stack and the compiled slug size has grown up to 40.5Mb! Previous to that last git push, the slug size was about 20Mb and was using rails v2.3.5.
Is it because my slug has both of rails versions installed? Probably I'm missing something but I haven't added any special code/files into my app as to increase the slug size by ~20Mb.
Can you point me on how can I reduce the slug size?
Any help will be greatly appreciated.
Thank you very much in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有帮助的一件事是将
.slugignore
文件添加到项目的根目录中,以告诉 Heroku 不要将某些文件或目录编译到 slug 中。我的看起来像这样:public
条目位于其中,因为我提供来自 Amazon S3 服务的所有静态文件;如果您不使用外部内容交付系统,请保留该行。One thing that helps is adding a
.slugignore
file to the root of your project to tell Heroku not to compile certain files or directories into the slug. Mine looks like this:The
public
entry is in there because I serve all static files from Amazon's S3 service; just leave that line off if you're not using an external content-delivery system.如果您在 cedar 堆栈上使用 less/bootstrap,那么您可以通过预编译和编写预编译和推送脚本来减少 slug 大小,以便不包含 less gem 和依赖项,请参阅 此处。
If you're using less/bootstrap, on the cedar stack, then you can reduce slug size by precompiling and scripting up your precompile and push so that the less gem and dependencies are not included see here.
您还可以排除生产环境中未使用的任何 gem,以稍微减少一些内容。确保您的 Gemfile 根据环境拆分 gem,然后排除那些不需要的环境。
摘自 Heroku 博客,此处
You can also exclude any gems that aren't used in production environment to trim things down a bit. Make sure your Gemfile splits gems according to environment and then exclude those environments that aren't needed.
Taken from a Heroku blog which is here