bullet-train-co / bullet_train

The Open Source Ruby on Rails SaaS Template
MIT License
1.65k stars 257 forks source link

Why do we check for `heroku?` #1114

Open jagthedrummer opened 11 months ago

jagthedrummer commented 11 months ago

These both seem overly specific.

https://github.com/bullet-train-co/bullet_train/blob/6dd1c9d2a252cdcb36b778120ffc775270148ab2/config/initializers/sidekiq.rb#L1

https://github.com/bullet-train-co/bullet_train/blob/6dd1c9d2a252cdcb36b778120ffc775270148ab2/config/initializers/redis.rb#L1

Would Rails.env.production? work there instead?

Related Discord thread: https://discord.com/channels/836637622432170028/1164303630439030876

jagthedrummer commented 11 months ago

After looking at this a little more I think it makes sense that we check whether we're on Heroku for these particular things because Heroku happens to be particularly bad about their recommendations around SSL for their Redis offerings.

https://help.heroku.com/HC0F8CUS/redis-connection-issues

Issue

Your app is no longer connecting to Redis and you are seeing errors relating to self-signed certificates.

Eg: <OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain)> SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain)

Resolution

Production plans (Premium and higher) of Heroku Data for Redis running Redis 6+ require TLS connections. Heroku Data for Redis uses self-signed certificates, which can require you to configure the verify_mode SSL setting of your Redis client.

To disable certificate verification, add { verify_mode: OpenSSL::SSL::VERIFY_NONE } (or your language equivalent) to your Redis connection configuration.

I think we just need a more reliable way of determining whether we're on heroku. Probably something like looking for ENV['HEROKU_APP_NAME'].

andrewculver commented 11 months ago

Yeah, that's 100% why I added this.