Have you ever seen this error when you tried to deploy to your Heroku app?
Compiled slug size: 500.6M is too large (max is 500M)
You can’t deploy but don’t fret. Here’s a few ways to reduce the slug size.
Install the Heroku Repo plugin:
heroku plugins:install heroku-repo
heroku repo:gc --app your-app-name
heroku repo:purge_cache --app your-app-name
These commands will execute
git gc --agressive (git-clean) and
delete the contents of the Heroku build cache stored in
your application’s Git repository.
Doing this on a recent app reduced my slug size by 100M.
Move internal design documents (
.sketch files) somewhere like Dropbox. Move
user-facing media (
.mpg files) somewhere like Amazon S3.
Follow Heroku’s instructions to
ignore files such as unit tests with
Hopefully each Ruby gem in your Bundler groups is being used by the app, but do a quick audit and remove any that aren’t used.
Heroku accepts an environment variable to limit the Ruby gems you bundle and cache.
heroku config:set BUNDLE_WITHOUT="development:test" --app your-app-name
Rails’ asset pipeline is a tempting area to try to optimize for slug size. App stylesheets, scripts, and images add up.
Hopefully these tips get you deploying again within a few minutes. Good luck!