10

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.

3 Answers3

18

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:

*.psd
*.pdf
test
spec
features
doc
public

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.

James A. Rosen
  • 64,193
  • 61
  • 179
  • 261
  • 1
    Yeah, I know mine includes the public/images directory + stylesheets + javascripts because I keep them on S3. I've upgraded to Rails 2.3.8 (was using 2.3.6) and the slug size has been reduced considerable to what it was before (~20Mb). I think it was some gem dependency issue. Thanks for your response anyway. – Estanislau Trepat Jun 01 '10 at 09:36
  • 1
    Is it safe to add the script dir to .slugignore? – fphilipe Sep 19 '10 at 08:14
  • 1
    That's a good question Philipe, did you find out if it is safe to do so? – digitalWestie Apr 20 '11 at 15:16
  • 2
    I tried it and the app runs fine but you can't fire up a console on Cedar with script in slugignore. – swrobel Mar 16 '12 at 15:28
2

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.

Damon Mannion
  • 324
  • 2
  • 3
  • You wrote a really good and relevant blog post, but I think you cheapen it with the URL shortener. – danneu May 15 '12 at 16:30
1

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.

heroku config:add BUNDLE_WITHOUT="development:test:staging"

Taken from a Heroku blog which is here

Simmo
  • 1,717
  • 19
  • 37