-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker issues with .env file variables #170
Comments
Thanks for the writeup @AlexHTW! I don't have time to look into this either (nor do I have any significant docker experience 😃), but I hope someone can shed some light on it! |
As I encountered an issue with the parsing of enquoted values in the .env file while using the docker-run command, I realized that essential values such as tokens, when enquoted, caused the bot to fail during startup. Furthermore, enquoted values led to incorrect behavior or error messages during runtime. To resolve this issue, I made sure not to use quotes in my .env file when defining values. Instead of writing: makefile TELEGRAM_BOT_TOKEN="123456:ABC-DEF" I wrote: ruby TELEGRAM_BOT_TOKEN=123456:ABC-DEF By removing the quotes, I avoided any parsing problems. As long as I didn't have any spaces or special characters in my values that required quotes, my bot worked fine without using them. |
Thanks for the input @NoobGinger. I wonder what's the best way to handle variables that require spaces i.e. |
No problem man.To handle spaces in ASSISTANT_PROMPT, replace spaces with underscores in the .env file and use this line in main.py 'assistant_prompt': os.environ.get('ASSISTANT_PROMPT', '').replace('_', ' ') or 'You are a helpful assistant.', This will replace underscores with spaces when reading the value. |
I am experiencing the same Issue with the USER_IDs |
Removed quotes from all vars in |
Problem description
Using the docker-run command doesn't parse enquoted values in the .env file correctly.
If essential values such as the tokens are enquoted, the bot will fail to start. If other values are enquoted it will lead to wrong behaviour or error messages during runtime.
Related Issues
#140 #168
Cause
docker run
doesn't parse .env files by a shell.docker compose up
or running it locally withpython bot/main.py
does use shell parsing.Current workaround
Remove all quotation marks in the .env file. (Correct behavior not tested for all of the variables, but so far so good.)
Additional issue with .env file for future development
Changes to the .env file within the program can not be persisted when using docker, blocking #139 and #108.
Goal
(1) A unified environment file that works with all three options of running the bot and (2) is mutable from within the docker container.
Solution ideas
README
and.env.example
ormain.py
if neededentrypoint.sh
for docker run anddocker-compose.yml
for docker compose up to define this behaviourLooking forward to input from people who have some docker experience (I don't 😛).
The text was updated successfully, but these errors were encountered: