question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include .env.local in Docker example

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
itsrennymancommented, Jul 15, 2021

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:

Note: similar to Default Environment Variables, .env.test file should be included in your repository, but .env.test.local shouldn’t, as .env*.local are intended to be ignored through .gitignore.

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.

0reactions
balazsorban44commented, Jan 27, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found