Include .env.local in Docker example
See original GitHub issueWhat example does this report relate to?
with-docker
What version of Next.js are you using?
Latest
What version of Node.js are you using?
Latest
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
other platform
Describe the Bug
env.local
is not copied in the runner
phase. You will encounter issue if you use secret variables (non NEXT_PUBLIC
env variables):
Expected Behavior
Add COPY --from=builder /app/.env.local .env.local
in the runner phase to fix this issue
(PLEASE, challenge me if I’m wrong!)
To Reproduce
–
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Environment variables in Compose | Docker Documentation
The “.env” file . You can set default values for any environment variables referenced in the Compose file, or used to configure...
Read more >Docker ARG, ENV and .env - a Complete Guide - vsupalov.com
Stop struggling to build Docker images and configuring your dockerized apps. This is the complete guide to build-time arguments, environment variables and ...
Read more >A complete guide to using environment variables and files ...
Environment variables keep your app secure and flexible. This article will demonstrate that it's easy to pass both individual variables and files that ......
Read more >Working with .env files in docker and docker-compose
env.container are loaded inside the ubuntu container. The echo command is written with a trailing slash to prevent my current shell to expand ......
Read more >Taking Advantage of the docker-compose Environment ...
This tutorial teaches you how to use docker-compose environment variables to define different containers, environments, and more.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello,
Why did you need to copy the .env.local file into the docker image?
If you want to pass the variables in the node.js context, you can just add the “environment” vars when you launch your images from the cli (with the -e option) or with the environment key in a docker-compose.yml.
Also, for the non-node.js context, the NEXT_PUBLIC_**** vars needs to be passed as build args only at the build time.
In the docs there is a note:
So If you have for example a Github action that builds your docker image at every new release, you simply can’t do the .env copy because you don’t have it in the repository.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.