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.
A slug is essentially the compressed copy of your application comprising of your git repo along with packages that are installed at deploy time like gems, node_modules, etc. The maximum allowed slug size (after compression) is 500MB. Applications using multiple buildpacks especially can strain this limit.
When a new Dyno is started, the Dyno will have the same filesystem that was compiled when your application was built during deployment. To permanently store files, you will need to use a mass storage system such as AWS S3. AWS has a great public API, and plugins for all major languages and Frameworks.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With