friendo-bot
friendo-bot copied to clipboard
Fix .env loading bugs with special characters
Summary
Our environment variables are potentially missing data in prod due to the special character "$" being stripped. We should consider migrating to a different method of loading our .env file in our prod docker deployment to fix this.
For now a quick fix is to wrap environment variables in single quotes to prevent them from being interpreted via bash on linux.
I believe the python-dotenv package will fix this as it parses the dotenv file differently to allow for special characters as seen below.
The syntax of .env files supported by python-dotenv is similar to that of Bash:
# Development settings
DOMAIN=example.org
ADMIN_EMAIL=admin@${DOMAIN}
ROOT_URL=${DOMAIN}/app
If you use variables in values, ensure they are surrounded with { and }, like ${DOMAIN}, as bare variables such as $DOMAIN are not expanded.
here's a link to the pypi site where I found this little snippet https://pypi.org/project/python-dotenv/#getting-started