# Use Environment Variables As Config Substitute

**URL:** https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828
**Category:** Core Development
**Tags:** docker
**Created:** [23 February 2024 18:24 UTC](https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828 "2024-02-23T18:24:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mlschuh](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@mlschuh](https://discourse.nodered.org/u/mlschuh)
#### Post date: [23 February 2024 18:24 UTC](https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828/1 "2024-02-23T18:24:26Z")

</div>

Hello,

I have many instances where I manage quite a few NodeRED instances deployed via Docker. For a variety of reasons, it would be extremely useful to be able to adjust the settings in `settings.js` via env variables so I don't need to touch every file on deploy. For example, setting the `credentialSecret` value.

Would the project be willing to accept a PR that would essentially follow the Grafana methodology that gets expanded on deploy. See [Configure Grafana | Grafana documentation](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#override-configuration-with-environment-variables) for the general idea.

My proposal would essentially be to have any variable prepended with `NODE_RED_` (or other), followed by the object path. All in all, the code changes would be mostly adding a loop with the variables expanded into the config using something similar to [Lodash Documentation](https://lodash.com/docs/4.17.15#set).

I've looked at the current options (especially outlined in here: [Use of environment variables to set editor user name and password](https://discourse.nodered.org/t/use-of-environment-variables-to-set-editor-user-name-and-password/54345)) however I'd like to have something a bit more generic.

Is this something worth pursuing or are there considerations that I'm not seeing?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [23 February 2024 18:31 UTC](https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828/2 "2024-02-23T18:31:00Z")

</div>

> [@mlschuh](#):
>
> or are there considerations that I'm not seeing?

> [@mlschuh](#):
>
> I have many instances where I manage quite a few NodeRED instances deployed via Docker

Without knowing the reasons behind the choice of docker, have you looked at [FlowFuse](https://flowfuse.com)

---

<div class="post-metadata">

### Author: ![mlschuh](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@mlschuh](https://discourse.nodered.org/u/mlschuh)
#### Post date: [23 February 2024 19:23 UTC](https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828/3 "2024-02-23T19:23:03Z")

</div>

Indeed we have! I have spent some time with local installations over the last few weeks and there's a couple of key requirements that would likely make the instance vs device distinction not workable. For the most part, our deploys are a ton of bespoke instances, nothing that would be "Deploy 10 copies of this flow".

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [23 February 2024 20:25 UTC](https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828/4 "2024-02-23T20:25:37Z")

</div>

My own installs of Node-RED all have far more extensive env overrides than the default. Much of that is available on github - look for my alternate installer repo.

That also has a comprehensive systemd script that includes the option to use a local env file on startup. A great way to control the settings. Especially if, like me, you use local Node-RED installs instead of global.

---

<div class="post-metadata">

### Author: ![mlschuh](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@mlschuh](https://discourse.nodered.org/u/mlschuh)
#### Post date: [26 February 2024 14:52 UTC](https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828/5 "2024-02-26T14:52:08Z")

</div>

This is very similar to what I've done in the past but I've been shying away from having customized packages of things to avoid having documentation/processes bifurcated. I'm trying to spend that time seeing if I can contribute to projects so others can use them. This one strikes me as a good fit since there is a lot of discussion around Grafana and graphing related to Node-RED and the folks over at Grafana set a nice precedent for it.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [26 April 2024 14:52 UTC](https://discourse.nodered.org/t/use-environment-variables-as-config-substitute/85828/6 "2024-04-26T14:52:55Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
