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

[Bug]: Pest complains about missing .env file when run within a docker container #1028

Open
PatrickMessierGoC opened this issue Dec 6, 2023 · 2 comments
Labels

Comments

@PatrickMessierGoC
Copy link

What Happened

When running Pest tests inside a docker container that does NOT contain either a .env.testing or a .env file, we systematically get the following warning when the first 2 tests are executed : → file_get_contents(/usr/share/nginx/lp-opn/.env): Failed to open stream: No such file or directory .

image

Environment variables are injected inside the container using docker compose env_file option.

image

Surprisingly, the rest of the test are running just fine.

We don't have this behaviour when running equivalent tests with phpunit.

How to Reproduce

Starting with an existing Laravel app with a Pest Test suite:

  1. Create a .dockerignore file and add .env and .env.testing to it.
  2. Build a docker container with the application code
  3. Start the application container.
  4. Execute the Laravel Pest Suite from within the docker container.

Sample Repository

https://dev.azure.com/CSPS-EFPC-UX/learning-platform/_git/lp-opn

Pest Version

2.24.0

PHP Version

8.1.26

Operation System

Linux

Notes

No response

@fabio-ivona
Copy link
Collaborator

Have you tried to load the env file in the volume?

@PatrickMessierGoC
Copy link
Author

PatrickMessierGoC commented Dec 6, 2023

@fabio-ivona No. In fact, the question here is not about getting the env files in the container but rather about why Pest behaves this way when the environment variables are "injected" in the container rather than defined via an .env.testing file that sounds like optional based on Laravel Docs. We know the environment variables are somehow available in the container because all remaining tests runs successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants