-
Notifications
You must be signed in to change notification settings - Fork 264
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
Add support for reading a .env file #249
base: main
Are you sure you want to change the base?
Conversation
By any chance did you see #232 ? |
So... the order of precedence (fallback if not defined) for env variables is:
Correct? And the fallback won't ever "overwrite" already existing ones. Pity we cannot do this under Windows, we also try hard to keep feature-parity. Note I'm also looking to #232, that doesn't require any external stuff (surely it's a little more "fragile" about what can process, but also, surely, what it supports is enough for moodle-docker) and comes with Windows support. Ciao :-) |
Hi @andrewnicols , Pros: simple change I’ve read the shdotenv readme and understand their rationale. I’m not sure it applies so much in this case, as this is a dev tool. I’d probably prefer a solution that works in windows (as well as mac and linux), and that doesn’t require extra dependencies, over one that’s a bit more secure (again, only because this is a dev tool). In this regard the proposed solution in #232 is a bit better. However, I don’t think it’s quite ready either. I’ll update #232 with similar feedback to here, but I think the use of So I think the way forward here is go with #232 plus the suggested changes. Or update this issue to implement it in a similar way. I’m keen to see this functionality merged in. Cheers, |
Just for the record, I don't see much value in either solutions TBH, they seem like an overkill for the simple env vars loading from the file. I am using very simple approach for this. I have a folder with collections of env files and I load the one I currently need for tests. For example, the content of
Then to start the containers for new environment, execute:
(the disadvantage of this approach is that each env file should override previously loaded env, i.e. they should match in terms of vars they define, but it works for my local dev requirements) |
I just done a quick test with a patch:
It actually works and good thing that env vars are runtime specific (not propagated to shell like in my example in the comment above). To test, apply the patch and execute |
Yeah, I think that to load from env file (ideally dotenv file) is quite possible, like both this and #232 are proposing. But we need the solution to be:
With both points fulfilled, I'm happy with any solution, really. I'm also using here some pre-configured "env" files that I source all the time. Ciao :-) |
This commit adds support for a .env file to provide default environment configuration using the shdotenv project with an environment file in the POSIX format.
I have not (yet) been able to find a Window variant of shdotenv, and I'm not sure if there's already something built-in to Powershell or similar so this remains a Linux/MacOS feature for now.