Rails 6.0 + Heroku + Active Storage + VIPS
VIPS is a 3x faster and 10x less memory hungry image processor that is now available for Active Storage in Rails 6.0. Unfortunately By default Heroku doesn't support VIPS. Do you know of a working buildpack you tested that has VIPS support?
Whoops, misread Heroku as Hatchbox. The following would be how you would use VIPS on Hatchbox.io:
sudo apt install -y libvips libvips-dev libvips-tools
Thank you! I'm getting closer to a solution.
Buildpacks:
heroku buildpacks:add --index 1 heroku-community/apt
heroku buildpacks:add --index 2 https://github.com/brandoncc/heroku-buildpack-vips.git
heroku buildpacks:add --index 3 heroku/nodejs
heroku buildpacks:add --index 4 heroku/ruby
Add Aptfile to root with the following content:
libglib2.0-0
libglib2.0-dev
libpoppler-glib8
Add to Gemfile:
gem 'image_processing', '~> 1.2'
Example call from views:
post.image.variant(resize_to_fill: [500, 250, linear: true]).processed
The VIPS part now works with Heroku, but I'm still struggling with some bug. For some reason my CSS and JS files are not loading on Heroku, but they are loading fine locally.
Does https://github.com/brandoncc/heroku-buildpack-vips.git really required?
I'll be not really confident with this line https://github.com/brandoncc/heroku-buildpack-vips/blob/master/bin/compile#L52.
The VIPS part now works with Heroku, but I'm still struggling with some bug. For some reason my CSS and JS files are not loading on Heroku, but they are loading fine locally.
What kind of error do you have? Assets returns 404? All assets?
Does your app is configured with RAILS_ENV=production
in environment variables?
Thank you!
I'll try to remove what you are unsure about and report back. What's wrong with that line?
I was able to fix the CSS/JS issue. I just had to comment out these in production.rb, probably because in Rails 6.0 things differently. Need to learn about this...
# config.assets.js_compressor = Uglifier.new(harmony: true)
# config.assets.css_compressor = :sass
You're welcome :)
About https://github.com/brandoncc/heroku-buildpack-vips/blob/master/bin/compile#L52. It's more because we don't really know the author and what could contain https://bc-heroku-buildpacks.s3.amazonaws.com/vips/libvips-$VIPS_VERSION-$HEROKU_STACK.tar.gz. But that's only my point of view.
On one of our project, hosted on Heroku in production, We only have config.assets.css_compressor = :sass
commented. And config.assets.js_compressor = Uglifier.new(harmony: true)
is not commented.
Not sure but this may be related to sprockets
that is no longuer installed with Rails 6, since webpacker is now the default. (https://github.com/rails/rails/pull/33079)