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:
# 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.
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
./secrets
dir and containingtelegram_api_hash
andtelegram_api_id
files:Fill the files with the actual credentials:
Create
docker-compose.yml
, for example: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
$ docker run telegram-bot-api:latest error: expected TELEGRAM_API_ID or TELEGRAM_API_ID_FILE env vars to be set