-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
how can I handle multiple environments? #220
Comments
Do: $ cd my-project
$ touch .env
$ ssh prod
$ cd my-project
$ touch .env
$ exit
$ ssh qa
$ cd my-project
$ touch .env
$ exit Do Not: $ git add .env .env.production .env.qa |
I am sorry but I dont understand how this can be automated with a git-based deployment for example. How do I handle that? |
Yes, you would prepare your .env file on your remote host using FTP or SSH (maybe at the same time you’re setting up git). Then during deployment after you have pushed your new release via git and before you start your process, you could copy or symlink the .env file in place. If your remote host is something like Heroku, you do not need a .env file since the environment will already be populated with your configuration. |
I use azure but I ll probably change for heroku. Is there another solution
that allows for multiple environment files besides dot env ?
…On Sun, 5 Nov 2017, 06:15 Max Beatty, ***@***.***> wrote:
Yes, you would prepare your .env file on your remote host using FTP or SSH
(maybe at the same time you’re setting up git). Then during deployment
after you have pushed your new release via git and before you start your
process, you could copy or symlink the .env file in place. If your remote
host is something like Heroku, you do not need a .env file since the
environment will already be populated with your configuration.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABr9glKyqupA35upIi4mQsjWSWoYtxk8ks5szUSDgaJpZM4Ou1Q9>
.
|
I think there is no general right or wrong here. How you're handling environment variables is highly dependent on some of the following things:
|
I figured it out. |
Hi there! We are using the "multiple env files" model in many projects for a years and feeling very comfortable with it. I know that dotenv doesn't recommend to commit Please take a look at https://github.com/kerimdzhanov/dotenv-flow and star the repo if you're interested in. Any feedback is very appreciated, feel free to ask questions, create issues and submit your PR's. P.S. |
As a PaaS user (Zeit Now in my case), I think the only approach that makes sense to me is what @gkatsanos proposes - to use the .env file for local development, and use the PaaS provided method for saving environment variables for each deployment, seeing as you won't SSH the file in AFAIK. This would also support deployment from build servers like Bitbucket Pipelines without having to commit the .env files to the repo. I don't see any other way to keep .env files out of git and still use git based deployments to PaaS services (like Zeit and Heroku), am I missing something? I'd much prefer having multiple .env files (i.e. |
You can run multiple environments on node with custom-env, it's a dotenv dependent >> |
There is a solution - #272 (comment) |
I understand the single .env file policy for regular web apps. But how do I do it with a static frontend SPA, which I build for production on my LOCAL machine? There is no way of inserting ENV variables dynamically for a static website, so I must store them on my local machine. In essence I need two .env files: .env.development and .env.production. Or am I totally misunderstanding something? |
For frontend configuration, you should use something like webpack's environment variables. If you're using another bundler/compiler, I'm sure there's something similar. You might also find inspiration from create-react-app. |
is this a good solution? |
Here is what I am doing.
Which loads them in this order:
|
Here Ability to require/include other .env files ? it is a good solution... |
We recommend using a .env.vault for this today. You can couple it with https://github.com/dotenv-org/dotenv-vault#local-build |
Thanks for the great lib.
You recommend against having multiple env files
How can I handle having production, staging and development environments and each one has its own API keys and passwords without having multiple files?
The text was updated successfully, but these errors were encountered: