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

How to work with .env.test with Docker #141

Open
ArthurZaharov opened this issue Mar 19, 2021 · 3 comments
Open

How to work with .env.test with Docker #141

ArthurZaharov opened this issue Mar 19, 2021 · 3 comments

Comments

@ArthurZaharov
Copy link
Contributor

No description provided.

@AleksandrSeleznev
Copy link
Contributor

It works fine for now.
Also, if I'm not mistaken, we have to take a look to docker-compose.yml in the environment section.
The issue is that Docker by default fetch ENV variables from .env during building.
And, for example, if you have some variable defined in environment section and this variable has two different values in .env and in, for example, .env.test files, value would have precedence which is taking place in .env file.

Example:

  environment:
    - MAILER_SENDER_ADDRESS

.env file:
[email protected]

.env.test file:
[email protected]

In the docker container, the MAILER_SENDER_ADDRESS variable will be set as [email protected].

@EvgeniyEsaulkov could you confirm this, please?

@AleksandrSeleznev
Copy link
Contributor

Here is the article about this:
https://docs.docker.com/compose/environment-variables/

@EvgeniyEsaulkov
Copy link
Contributor

@EvgeniyEsaulkov could you confirm this, please?

Absolutely. Variables defined in docker-compose.yml are system variables for the container and will be fetched from the custom .env file only using the --env-file option - https://docs.docker.com/compose/environment-variables/#using-the---env-file--option

Rest of variables that are loaded to Rails via dotenv gem are available the same way as we work without Docker.

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

3 participants