-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Deprecate the env-var way of running under docker #5518
Comments
For clarity: we'll provide documentation on how to convert your environment-variable-configured docker image to a yaml-configured one. |
done by #5566. |
removed info about matrix-org#5518.
Since this is the place I point to when people say "why u no support env vars", let me say here for the record: It basically comes down to the fact that environment variables aren't powerful enough. With the old way of configuring synapse based on a handful of env vars, people kept discovering things that weren't supported, which was annoying for them and led to support headaches for us. (Just maintaining the template for the generated config was work which we didn't really have time for, and tended to forget, since it wasn't something that we used ourselves). Maybe you could come up with a generic scheme for mapping environment variables into configuration options, but that gets ugly quickly. For example, how would you give a (long) list of IPv6 addresses to include on the Our experience with orchestration via ansible, kubernetes, etc is that config files make for much easier templating than magic environment variables which then get turned into configuration files via a somewhat opaque process. We recommend using your orchestration system's templating support to deploy a config file rather than somehow setting environment variables in your containers. |
This isn't about ergonomics, at least not directly. I have, I hope, a clarifying question:
The assertion that "environment variables make things more complex" flies in the face of pretty much every piece of advice from the past decade or so. It's needing to coordinate data across multiple config files, in different formats, for different programs, in different languages that stops me in my tracks. Environment variables are a common denominator, and even permitting us to e.g. interpolate them (as single, static values) into the |
Interpolation into a config file (eg a reference to |
I've been looking through some matrix Kubernetes helm charts, like typokign/matrix-chart, and a recurrent theme is plain text passwords in the values.yaml that then get stored in plain text configMaps. The standard bitnami postgresql chart supports existingSecrets for passwords, but it looks like in a bunch of these matrix helm charts that reference the bitnami postgresql chart, they seem to take the postgres password exclusively as plain text anyway, so they can then use it to create the giant config file as a k8s configMap, rather than a k8s secret, and that's probably because an entire config file as a k8s secret would need to be base64 encoded, and I honestly don't know how to do that cleanly with go templates, plus I still wouldn't know how to pull from another existing secret for the postgres password to be cleanly integrated. Is there any way we can have just the secrets (such as postgres password, for instance) as env vars? Then, helm charts could use In the meantime, for writing/improving existing helm charts, the best I can do is change the configMap to a secret, and figure out how to base64 encode the entire thing, which probably isn't the worst, but I would still need a user of the helm chart to provide passwords in plain text, because there's no way to reference an existing secret from within a secret helm template (unless there is, in which case, please let me know as that would help quite a bit). Update: I also looked into referencing a k8s secret from a configmap, but there's not been success on moving that feature forward. I see this was talked about a bit in #14512 but that doesn't really talk about the use case in k8s specifically and that issue referenced this one anyway. I also read #5518 (comment) and #11489 but all the conversations drop off in 2022 and I can't find how people are doing this securely with k8s outside of maybe |
Since this is the issue usually referred to when people are looking for additional environment variables, I thought I'd put my docker compose solution here: I was looking for a way to create complex configurations in our development environments, more closely resembling our production environments, by automatically merging the default generated config with a more complex template. This is the approach I ended up with (simplified just to give the idea): Generate Config
compose.yaml:
The variables obviously have to be set via .env or the environment loaded via env_file. Also I didn't care about secrets in a strictly local WSL based development environment. Dockerfile:
generate.sh:
homeserver.yaml.tmpl:
This is obviously an extremely reduced sample. That approach works very well for our case. |
We've decided to stop supporting the configuration of synapse via environment variables.
The main reason for this is that you're bound to end up needing to do more things than it's possible to do with the environment variables, and the incomplete support leads to problems like #5430.
An alternative might have been to make it genuinely possible to configure everything via environment variables in some consistent fashion, but that sounds hard and more work than we're able to do.
The text was updated successfully, but these errors were encountered: