telegram-bot-api
telegram-bot-api copied to clipboard
Add docker secrets support for TELEGRAM_API_ID and TELEGRAM_API_HASH
Summary
Resolves #19
After this update users will be able to provide Telegram API credentials via env vars containing paths to files containing the actual values.
Example showcase:
- Create
./secretsdir and containingtelegram_api_hashandtelegram_api_idfiles:
secrets
├── telegram_api_hash
└── telegram_api_id
- Fill the files with the actual credentials:
$ echo "12345" > ./secrets/telegram_api_id
$ echo "ba78...165ad" > ./secrets/telegram_api_hash
- Create
docker-compose.yml, for example:
services:
telegram-bot-api:
build: .
environment:
# in this section we set paths to the mounted secrets:
TELEGRAM_API_ID_FILE: /run/secrets/telegram_api_id
TELEGRAM_API_HASH_FILE: /run/secrets/telegram_api_hash
secrets:
# here we define list of secrets that will be used by the service
- telegram_api_id
- telegram_api_hash
secrets:
# here we define the secrets and their location on the host machine:
telegram_api_id:
file: ./secrets/telegram_api_id
telegram_api_hash:
file: ./secrets/telegram_api_hash
Notes
I've also included checks for env vars presense:
$ docker run telegram-bot-api:latest
error: expected TELEGRAM_API_ID or TELEGRAM_API_ID_FILE env vars to be set
I think this will slightly improve user experience and will not break anything, as environmental variables containing Telegram API credentials were essential to run the telegram-bot-api anyway.
Please share your thoughts and whether any changes needed. Then I will update the README file to reflect the usecase changes.