Search code examples
environment-variablesddev

Make use of .env variables in DDEV's config.yaml?


I'd like to be able to define the variable values in DDEV's version-controlled ./ddev/config.yaml file, using the non-version-controlled .env file. For example (pseudo-code):

name: env($PROJECT_NAME)
# etc...

I can't rely on remembering to swap out config.yaml files or any other manual steps.

The reason for the season is that I need to have multiple DDEV instances of the same site. Each instance would be committing to the same repo, but may (or may NOT) have different branches. In other words, they need to be capable of being merged with each other, without DDEV getting mixed up. Since I have .ddev/config.yaml committed to the repo, I need some other way of having separate DDEV instances.


Solution

  • You probably want to use config.*.yaml for this. By default, config.*.yaml are gitignored. For example, config.local.yaml might have local overrides. See the docs for more info.

    I haven't experimented with using the .env file in this context, but I know that config.local.yaml will work fine for this use.