telegram-bot icon indicating copy to clipboard operation
telegram-bot copied to clipboard

Needs credentials when building assets with SECRET_KEY_BASE_DUMMY

Open thomaswitt opened this issue 1 year ago • 3 comments

When building a docker image, it is recommended practice to do that as follows

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile

This will cause Telegram::Bot to fail with Telegram::Bot::Client :default not configured.

I helped myself with using the following code in config/routes.rb:

  unless ENV['SECRET_KEY_BASE_DUMMY']
    telegram_webhook TelegramWebhooksController
  end

But it feels ugly and I think there should be a better out of the box solution, as everybody will have this problem who tries to deploy via docker

thomaswitt avatar Oct 10 '24 13:10 thomaswitt

I encountered the same issue. Ideally, it would be great to have the option to configure the Telegram token separately, in an initializer. Otherwise, it's not immediately clear where this configuration is happening.

For now, I'm using the same workaround.

dankimio avatar Oct 17 '24 10:10 dankimio

It's possible to configure bots in an initializer. See Configuration in readme.

Token is used to build a route. So you'll have to use some workaround if you want to run app without secrets. Either this or add a token placeholder.

printercu avatar Oct 18 '24 20:10 printercu

@printercu If that's the way to go, I would suggest to mention it somewhere in the documentation, because everybody who builds a docker image with Rails and your gem will fall into that trap.

thomaswitt avatar Nov 08 '24 09:11 thomaswitt