Jets Uploads Image Processing

When you use ActiveStorage .variant helper method to create images of different sizes like so

@photo.image.variant(resize_to_limit: [300, 300])

It uses an image_processing gem underneath-the-hood.

System Package Dependencies

The image_processing gem requires the imagemagick or libvips system package to be installed. Jets detects will installs both packages for the Docker image when it detects that you have the image_processing. You do not have to configure it.

In the future, if new libraries support is added to the image_processing gem, here’s how you would add additional libraries for them.

config/jets/deploy.rb

Jets.deploy.configure do
  config.dockerfile.apt.packages.all_stages = ["new-image-processing-package"]
end

ActiveStorage Background Processing

ActiveStorage processing work handling is handled by different ActiveStorage Active Jobs. The default Rails.application.config.active_job.queue_adapter is async which should only be used for dev/test.When you configure the config.active_job.queue_adapter to :jets_job

To enable the creationg of Jets Job resources to handle ActiveJob work:

config/jets/deploy.rb

Jets.deploy.configure do
  config.job.enable = true
end

This creates:

  1. The SQS Queue to store the jobs
  2. The Lambda Function that listens to Queue events and processes the jobs

AWS Lambda scales automatically to process the queue.

Jets Job ActiveJob Adapter

Jets provides a jets_job ActiveJob adapter that queues jobs to SQS. To enable it:

config/environments/production.rb

Rails.application.configure do
  config.active_job.queue_adapter = :jets_job
end

Related: Jets Jobs Enable.