Skip to content
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

Load environment variables from alternate .env files #875

Open
jschuur opened this issue Apr 26, 2024 · 0 comments
Open

Load environment variables from alternate .env files #875

jschuur opened this issue Apr 26, 2024 · 0 comments

Comments

@jschuur
Copy link

jschuur commented Apr 26, 2024

Currently, partykit deploy will look for .env and .env.local for its environment variables. However, when I do a deploy to a preview environment e.g. I'd like it to use .env.preview or .env.production for the production deploy.

Ideally, a --env-file=.env.preview would override the default file(s) used.

Previously discussed on Discord, including this explanation:

raimundo (kalendme.com): ran into this exact issue @joostschuur , the problem is that currently partykit automatically traverses directories up looking for a .env and if you have one, it also loads env vars from it
raimundo (kalendme.com): so if you happen to have a .env file near it it'll also source from it, silently overwriting the ones you passed

Another angle here is that for the partykit server, you usually want to only share a subset of the contents of your environment specific .env file, since your main app code will likely use different secrets and settings.

It would be nice to pick certain ones from the CLI (or partykit.json?) and use it in conjunction with dotenv -e .env.preview e.g..

This did not currently work though:

dotenv -e .env.preview -- partykit deploy --preview preview \
--var DATABASE_URL=$DATABASE_URL \
--var DATABASE_AUTH_TOKEN=$DATABASE_AUTH_TOKEN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant