jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.83k stars 187 forks source link

[devbox.json] support env_from dotenv files #2174

Closed mohsenari closed 4 days ago

mohsenari commented 6 days ago

Summary

NOTE: Docs update PR will follow. As per request from users, I added support for env_from field being able to take a path to *.env file and have those env variables available in devbox shell and run.

If a duplicate env variable is specified in both .env and in the "env" section of devbox.json, the env section from devbox.json takes priority and overwrites. This I believe is the correct behavior but I'm open to discussion.

How was it tested?

see test file at testscripts/run/envfrom.test.txt

Lagoja commented 5 days ago

Do .env files (and our parser) also support the following format:

export S3_BUCKET=YOURS3BUCKET
export SECRET_KEY=YOURSECRETKEYGOESHERE
mohsenari commented 5 days ago

Do .env files (and our parser) also support the following format:

export S3_BUCKET=YOURS3BUCKET
export SECRET_KEY=YOURSECRETKEYGOESHERE

@Lagoja not common but .env file format seems to have export in front of each line in some cases . But because .env doesn't have an official standard (although dotenv.org claims to be the creator of dotenv), some others specifications don't support the export. So ultimately, it's up to us if we want to add it in our parser. Currently, the parser doesn't support it.

Lagoja commented 5 days ago

I think I'm ok to add it later, current functionality is probably good for now