Reputation: 9415
I've already spent half the day trying to debug a Heroku error where I can't push code to my staging server because of a slug compilation error:
Compiled slug size: 320.5MB is too large (max is 300MB).
I've moved all assets to AWS3 and created a .slugignore file with the following information:
*.psd
*.pdf
test
spec
features
doc
public
What other strategies can I use? The strangest thing is that, as far as I know, the code is the same as the production server, and I don't get any errors with pushing to the production server.
Upvotes: 12
Views: 23654
Reputation: 5847
When using Heroku and Wicked PDF gem, sometimes you may have the binaries included in your Gemfile. These are huge. Use wkhtmltopdf-heroku binary :
gem 'wkhtmltopdf-binary', '~> 0.12.6', group: [:development, :test]
gem 'wkhtmltopdf-heroku', '~> 2.12.6', group: [:production]
This took my slug size, I think, from over 500 mb to 150mb!
There are other solutions to get the binaries out of your slug such as separate buildpacks as well.
Upvotes: 6
Reputation: 1
I also got the same error and removing the unnecessary dependencies in requirement.txt solved the problem. So try removing some dependencies which are not in use in your app. Hope it helps!
Upvotes: 0
Reputation: 21
I know this is for Ruby on Rails but for my project I had many python dependencies which added tremendously to the slugsize.
So I reckon that you could separate your dependencies for development and production (heroku).
Upvotes: 0
Reputation: 6891
Your slug size is displayed at the end of a successful compile after the Compressing message. The maximum allowed slug size (after compression) is 500 MB.
You can inspect the extracted contents of your slug with
heroku run bash
and by using commands such asls
anddu
.
Slug size varies greatly depending on what language and framework you are using, how many dependencies you have added and other factors specific to your app. Smaller slugs can be transferred to the dyno manager more quickly, allowing for more immediate scaling. You should try to keep your slugs as small and nimble as possible.
Here are some techniques for reducing slug size:
.slugignore
.Upvotes: 0
Reputation: 186
This worked for me:
$ heroku repo:gc -a appname
$ heroku repo:purge_cache -a appname
$ heroku repo:reset -a appname
Upvotes: 0
Reputation: 2288
In my case I forgot to add buildpacks, so my slug was reaching 624.4MB
What I did is to add these ones:
After delpoying again, my slug size was 393.9MB
Upvotes: 0
Reputation: 12514
this worked for me
$ heroku repo:gc -a appname
Will run git gc --aggressive on your repo.
$ heroku repo:purge_cache -a appname
Then I mannually pushed code to heroku
$ git push heroku-prod master
Upvotes: 8
Reputation: 6138
It's possible that before you added the .slugignore file you had some large files added the git repo and now they are in the slug cache or as git refs. The git-repo plugin has commands to fix these problems:
$ heroku repo:gc -a appname
Will run git gc --aggressive on your repo.
$ heroku repo:purge_cache -a appname
This will delete the build cache and then you probably should run to rebuild the application.
$ heroku repo:rebuild -a appname
Upvotes: 21