Closed YesCT closed 6 months ago
Are .env files required? What error do you get without the file?
@YesCT why did you need to add it, what happens without it? .env files should only be for local development, not remote deployments
@davereid @justafish we were getting this error at the 'Install and Start DDEV' step
env file /home/runner/work/project/project/.env not found: stat /home/runner/work/project/project/.env: no such file or directory
Failed to start project: composeCmd failed to run 'COMPOSE_PROJECT_NAME=ddev-project docker-compose -f /home/runner/work/project/project/.ddev/.ddev-docker-compose-base.yaml -f /home/runner/work/project/project/.ddev/docker-compose.env-file.yaml config', action='[]', err='exit status 14', stdout='', stderr='env file /home/runner/work/project/project/.env not found: stat /home/runner/work/project/project/.env: no such file or directory'
Error: Process completed with exit code 1.
I don't see docker-compose.env-file.yaml
coming from drainpipe at all, should the project possibly be re-configured to not require an .env file on non-local environments or gracefully proceeding instead of failing?
I also think generally we encourage the use of https://github.com/vlucas/phpdotenv as a require-dev dependency instead of loading the .env file via DDEV configuration.
The DDEV docs themselves say to use a .ddev/.env
file and do not reference loading .env files at the root directly: https://ddev.readthedocs.io/en/latest/users/extend/customization-extendibility/#providing-custom-environment-variables-to-a-container
I noticed that we have docker-compose.env-file.yaml
inside .ddev
with the following:
services:
web:
env_file:
- ../.env
This file was causing the error. Thank you for your help!
@justafish @davereid Thank you so much for pointing us in the right direction.
Closing this since my questions are answered. :)
For pantheon multidev deploys, we needed to add:
We plan to have a followup to prevent the change from being overwritten with something like https://github.com/Lullabot/drainpipe/blob/main/README.md#nightwatch
Question 1: Are we missing something else where we should be setting .env?
Question 2: Is this common enough that making sure .env isn't empty should be added to the default scaffold file??