Closed ericfranz closed 4 years ago
If we did it this way we would have to use ::Dotenv.overload
for the local files or else env vars already set would not be overriden.
Another negative is each app will need to specify this:
OOD_ENV_LOCAL="/etc/ood/config/apps/$APP_TYPE/$APP_NAME/env"
At which point, we could just be updating each app manually to load these extra files i.e. inserting Dotenv.load
into the appropriate location in the Rails app (that would have probably been a faster solution though anyways than what it turned out to be).
And it is not backwards compatible with the existing dotenv files.
There is a third solution that I haven't explored yet. That is to just move to using yaml configuration files in /etc/ood/config. That would require more exploration and design.
I think prefer this to the original option. Though the original option does have tests written that works. This option loads the .env.local files, then the external files, and finally the original load, which means that now variables set in .env.local can be used inside the .env and .env.production files. So that is a change of behavior from previous.
If we did it this way we would have to use
::Dotenv.overload
for the local files or else env vars already set would not be overriden.
We shouldn't set variables in the app's .env
if we intend on it being customizable, although a developer can easily override a specific global variable now. An example being:
# /etc/ood/config/apps/dashboard/env
OOD_DASHBOARD_SUPPORT_EMAIL="oschelp@osc.edu"
and I want to override that value, I can set in my app:
# .env.development
OOD_DASHBOARD_SUPPORT_EMAIL="bad@email.com"
OOD_ENV_LOCAL="/etc/ood/config/apps/dashboard/env"
Another negative is each app will need to specify this:
OOD_ENV_LOCAL="/etc/ood/config/apps/$APP_TYPE/$APP_NAME/env"
Only system apps, as it would not be feasible for a sys admin to install env
files under /etc/ood/config/apps
for all shared/development apps.
There is a third solution that I haven't explored yet. That is to just move to using yaml configuration files in /etc/ood/config. That would require more exploration and design.
I am all for a config.yml.erb
format. Since it gives us the dynamic nature of the dotenv
gem but also the power of Ruby.
Although this has issues for Python and Node.js apps. Unless we use the external erb
CLI tool.
Although it should be noted that the dotenv
library for Node.js does not support Bash code. It just expects a key-value format made up of strings separated by =
.
So a simple config.yml
would suffice.
The apps have their own solution for now.
What about something like this?
Where we remove the need for
.env.local
completely, and instead only load the versioned environment files. Then we allow the app to specify another environment file after the fact.So my app's
.env.production
file could look like: