Joy of Rails uses DigitalOcean Spaces for image storage in production.
DigitalOcean Spaces are S3-compatible so technically not much different from using Amazon S3. I chose DigitalOcean Spaces because Joy of Rails is already using DigitalOcean for the virtual private server to host the application. That keeps things simpler in my mind.
The DigitalOcean interface makes it pretty easy to set up. This tutorial, although a bit older, is still relevant. It provides all the info you would need to go from "zero-to-DigitalOcean" for ActiveStorage.
As far as Rails configuration goes, here are the key bits:
A section in config/storage.yml
to set credentials to DigitalOcean.
digitalocean:
service: S3
access_key_id: <%= Rails.application.credentials.dig(:digitalocean, :access_key) %>
secret_access_key: <%= Rails.application.credentials.dig(:digitalocean, :secret) %>
bucket: <%= Rails.application.credentials.dig(:digitalocean, :bucket) %>
endpoint: https://nyc3.digitaloceanspaces.com
region: us-east-1
A section in in my encrypted credentials file to store the access key, secret, and bucket name I generated in the DigitalOcean interface.
digitalocean:
access_key: DOxxxxxxxxxxxxxxxxxx
secret: aaaabbbbccccddddeeeeffffxxxxxxxxxxxxxxxxxxx
bucket: my-bucket-name
A setting in config/environments/production.rb to point ActiveStorage to DigitalOcean.
# Store uploaded files on digitalocean (see config/storage.yml).
config.active_storage.service = :digitalocean