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

Add touch .env to scaffolding #468

Closed
YesCT opened this issue Mar 6, 2024 · 7 comments
Closed

Add touch .env to scaffolding #468

YesCT opened this issue Mar 6, 2024 · 7 comments
Labels
question Further information is requested

Comments

@YesCT
Copy link
Contributor

YesCT commented Mar 6, 2024

For pantheon multidev deploys, we needed to add:

$ git diff
diff --git a/.github/actions/drainpipe/ddev/action.yml b/.github/actions/drainpipe/ddev/action.yml
index e0c250b5e..8188bedc3 100644
--- a/.github/actions/drainpipe/ddev/action.yml
+++ b/.github/actions/drainpipe/ddev/action.yml
@@ -22,10 +22,6 @@ inputs:
 runs:
   using: "composite"
   steps:
-    - name: Create empty env file
-      run: touch .env
-      shell: bash
-
     - name: Install and Start DDEV
       run: |
         curl https://apt.fury.io/drud/gpg.key | sudo apt-key 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

"extra": {
        "drupal-scaffold": {
            "file-mapping": {
                ".github/actions/drainpipe/ddev/action.yml": {
			"mode": "skip"
		}
	}
}

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

@davereid
Copy link
Member

davereid commented Mar 7, 2024

Are .env files required? What error do you get without the file?

@deviantintegral deviantintegral added the question Further information is requested label Mar 7, 2024
@justafish
Copy link
Member

@YesCT why did you need to add it, what happens without it? .env files should only be for local development, not remote deployments

@leonel-lullabot
Copy link
Collaborator

@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.

@davereid
Copy link
Member

davereid commented Mar 7, 2024

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?

@davereid
Copy link
Member

davereid commented Mar 7, 2024

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

@leonel-lullabot
Copy link
Collaborator

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!

@YesCT
Copy link
Contributor Author

YesCT commented Mar 7, 2024

@justafish @davereid Thank you so much for pointing us in the right direction.

Closing this since my questions are answered. :)

@YesCT YesCT closed this as completed Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants