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

Ignore .env and .env.build for deployments by default #2083

Merged
merged 1 commit into from
Apr 5, 2019

Conversation

TooTallNate
Copy link
Member

Because now dev uses these dotenv files to define the Now secrets to use, it would be bad practice to include them in the deployment files since they will be using development values instead of production values.

Because `now dev` uses these dotenv files to define the Now secrets to
use, it would be bad practice to include them in the deployment files
since they will be using development values instead of production values.
@TooTallNate TooTallNate requested a review from leo April 4, 2019 00:21
@codecov-io
Copy link

Codecov Report

Merging #2083 into canary will decrease coverage by 0.13%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           canary   #2083      +/-   ##
=========================================
- Coverage    4.63%   4.49%   -0.14%     
=========================================
  Files         243     243              
  Lines        8572    8572              
  Branches      873     873              
=========================================
- Hits          397     385      -12     
- Misses       8158    8170      +12     
  Partials       17      17
Impacted Files Coverage Δ
src/util/ignored.ts 100% <ø> (ø) ⬆️
src/util/get-project-name.js 90.9% <0%> (-9.1%) ⬇️
src/util/get-files.js 91.53% <0%> (-8.47%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 658c220...7efa0a0. Read the comment docs.

@leo leo merged commit 4fb043c into canary Apr 5, 2019
@leo leo deleted the update/dotenv-ignore branch April 5, 2019 00:11
leo pushed a commit that referenced this pull request Apr 5, 2019
Because `now dev` uses these dotenv files to define the Now secrets to
use, it would be bad practice to include them in the deployment files
since they will be using development values instead of production values.
@antmarot
Copy link

antmarot commented Apr 8, 2019

This is a breaking change for us.
What's the recommended/easiest way to still upload .env files?

@leo
Copy link
Contributor

leo commented Apr 8, 2019

@antmarot We marked the release that includes this change a patch release because uploading .env poses a security risk. You should never do it, under any circumstance.

As defined in dotenv (the creator of .env), the file should only be used in development.

Please use secrets instead, which will encrypt your secrets upon upload.

@antmarot
Copy link

antmarot commented Apr 8, 2019

@leo Thanks for your reply. I totally understand the reason behind the change and I am convinced it was the necessary thing to do. I would however argue this is a breaking change though.

While dotenv strongly recommends against committing .env files, I don't think their use in production is considered bad practice. In my opinion, the question is more about how do you securely get that file there.

Anyway, my use case is not about secrets, but configuration values. I purposefully do not use the env section in now.json to avoid duplication of values (now is not the only place where we deploy).

If there is no flag or config to override the ignored .env I think I'll just rename it.

@leo
Copy link
Contributor

leo commented Apr 8, 2019

@antmarot I understand. In that case, you can use the --dotenv flag to have Now CLI convert the values inside that file into regular environment variables supported by Now for you.

@nnennajohn
Copy link

nnennajohn commented Jun 13, 2019

@leo Thanks for the headups. I must have searched through a dozen comments before finding this. This should be perhaps included in the docs.

Just to be clear, assuming I have .env file && .env.build in the root of a monorepo setup:
now dev would use the vars in .env?
now --dotenv would deploy my production build with the vars in env.build?

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

Successfully merging this pull request may close these issues.

None yet

5 participants