ddev-contrib icon indicating copy to clipboard operation
ddev-contrib copied to clipboard

Add env_file support on env snippet.

Open mrhorse opened this issue 2 years ago • 3 comments

The New Solution/Problem/Issue/Bug:

No env file support provided on the env snippet.

How this PR Solves The Problem:

Provides example snippet with comment. Allows docker-compose to load env files. This is a widely known issue with ddev, i.e. the lack of env file support.

Taken from the offical docs: https://docs.docker.com/compose/environment-variables/#the-env_file-configuration-option

Manual Testing Instructions:

  • Add snippet to .ddev folder
  • Add .env file to project root, declaring at least one environment variable.
  • Boot the ddev project. In the project code do print_r($_ENV);
  • Refresh front-end - given environment variable(s) in the env file should be present in the array.

Related Issue Link(s):

mrhorse avatar Mar 17 '22 23:03 mrhorse

Shouldn't this go into ddev's docs?

rfay avatar Mar 17 '22 23:03 rfay

As well as here? Probably. Found a solution and wanted to contribute back is all :) . The docs have pointed to this repo for anything on the level of adding custom docker-compose partials.

mrhorse avatar Mar 18 '22 00:03 mrhorse

Yeah, just improve https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#providing-custom-environment-variables-to-a-container - I've been meaning to explore this feature of docker-compose and didn't get it done yet.

rfay avatar Mar 18 '22 01:03 rfay