ddev / ddev-platformsh

Add integration with Platform.sh hosting service
Apache License 2.0
9 stars 10 forks source link

How to override platform.sh environment variables set in `.ddev/config.platformsh.yaml` ? #105

Closed jobee closed 1 year ago

jobee commented 1 year ago

First of all, huge thanks for providing this platform.sh ddev plugin. It looks great so far!

For local development, I need to override an environment variable that is set in .ddev/config.platformsh.yaml.

I tried all the places (.env, .ddev/config.yaml, .ddev/global_config.yaml) documented in here: https://ddev.readthedocs.io/en/latest/users/extend/customization-extendibility/#providing-custom-environment-variables-to-a-container

But it seems that .ddev/config.*.yaml is the one with the highest priority. I also found out that .ddev/config.zzz.yaml overrides .ddev/config.platformsh.yaml.

Would you consider this the recommended approach?

Update: Problem with .ddev/config.zzz.yaml is that I can't get it in Git easily, cause /config.*.y*ml is ignored in .gitignore :-/ So is there a way to solve this without touching #ddev-generated files?

rfay commented 1 year ago

Hi @jobee - I'm glad it's working for you.

If you want to override an existing environment variable (which one would it be?) you may want to try doing it with config.override.yaml. But what environment variable is it you need to override?

jobee commented 1 year ago

Hm. Should there be a special handling for the filename config.override.yaml? In my case it's not working. The config.*.yaml files seem to be alphabetically merged, so config.platformsh.yaml gets merged after config.override.yaml

The variable I'm trying to override is application specific. I maintain a Neos CMS project which sets Production / Development context via environment variable.

This gets pulled from PlatformSh:

# config.platformsh.yaml
web_environment:
...
- "FLOW_CONTEXT=Production/PlatformSh"
...

And I currently override it with:

# config.z.platformsh.override.yaml
web_environment:
    - FLOW_CONTEXT=Development/Ddev

I just don't know how to check in config.z.platformsh.override.yaml into Git without touching ddev's .gitignore.

jobee commented 1 year ago

btw

ddev version
 ITEM             VALUE
 DDEV version     v1.21.6
 architecture     arm64
 db               drud/ddev-dbserver-mariadb-10.4:v1.21.5
 dba              phpmyadmin:5
 ddev-ssh-agent   drud/ddev-ssh-agent:v1.21.5
 docker           20.10.20
 docker-compose   v2.15.1
 docker-platform  colima
 mutagen          0.16.0
 os               darwin
 router           drud/ddev-router:v1.21.5
 web              drud/ddev-webserver:v1.21.5
jobee commented 1 year ago

Oh wait. I just noticed I set FLOW_CONTEXT=... in my .platform.app.yaml I could just add it to the project variables via PlatformSh Console, so it's not part of the generated config.platformsh.yaml and then simply add:

# config.yaml
web_environment:
    - FLOW_CONTEXT=Development/Ddev

Problem solved. Sorry for bothering you.

rfay commented 1 year ago

Glad it's working, thanks for your feedback!