Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

Environment variables should be capitalized

Open adityapatadia opened this issue 1 year ago • 9 comments

Issue Summary

When using secrets manager like https://www.doppler.com/ the ENV variables are always enforced to be uppercase. It's always best practice to uppercase env variables to ensure compatibility across different shells.

Steps to Reproduce

Try to set uppercase env variable and it does not work.

Ghost Version

5.94

Node.js Version

20

How did you install Ghost?

Docker

Database type

MySQL 8

Browser & OS version

No response

Relevant log / error output

No response

Code of Conduct

  • [X] I agree to be friendly and polite to people in this repository

adityapatadia avatar Sep 17 '24 12:09 adityapatadia

Hey adityapatadia, thanks for raising the issue.

So that I understand your use case better, can you give an example of an env. variable that you'd like to set to uppercase?

sagzy avatar Sep 18 '24 09:09 sagzy

I meant any config that can be set with ENV variable. Take this example database__connection__password. If this is uppercase, Ghost does not recognise it. Ideally it should be possible.

adityapatadia avatar Sep 18 '24 09:09 adityapatadia

Got it, thank you for clarifying!

sagzy avatar Sep 18 '24 11:09 sagzy

I would consider this a bug in Doppler rather than Ghost.

While it's a convention that env vars are upper case, it's not a requirement.

It's always best practice to uppercase env variables to ensure compatibility across different shells.

And this assertion is false. No common shells or tools have a problem with env vars not being upper case.

The format of Ghost environment variables serve a specific purpose to map exactly to the names of valid values in Ghost's config file.

There is already complexity in the system by supporting both the JSON config configuration and the environment variables that match exactly.

Supporting another format of environment variables adds unnecessary complexity.

I suggest filing a bug with Doppler instead. They are failing to support valid environment variables.

markstos avatar Sep 21 '24 17:09 markstos

It's really impossible to set JSON config in container environments. ENV variables are the only option. Anyway it's a request to consider this.

adityapatadia avatar Sep 22 '24 15:09 adityapatadia

@adityapatadia may be you can try out this in your Dockerfile

    environment:
     database__connection__host: ${DB_HOST} # Use Doppler's uppercase
     database__connection__user: ${DB_USER}

imzedi avatar Sep 24 '24 06:09 imzedi

Sounds like a good idea but problem is doppler injects variables on RUN command and not before. Any idea if that would work in some way?

adityapatadia avatar Sep 27 '24 07:09 adityapatadia

Hello @adityapatadia i would like to work upon this issue.Please assign it to me.

ekayZ7875 avatar Oct 06 '24 20:10 ekayZ7875

This isn't really a bug, but I do accept it would be more convenient if uppercase env vars were supported.

The full context for why it is not supported lives in the nconf repo here - essentially, their implementation causes a jump in memory usag, which needs to be solved first.

If the issue in nconf is resolved, we can update Ghost and tweak the configuration if needed to support it.

Anyone can work on this - we don't assign issues outside of our regular contributors.

ErisDS avatar Dec 11 '24 13:12 ErisDS

Our bot has automatically marked this issue as stale because there has not been any activity here in some time.

The issue will be closed soon if there are no further updates, however we ask that you do not post comments to keep the issue open if you are not actively working on a PR.

We keep the issue list minimal so we can keep focus on the most pressing issues. Closed issues can always be reopened if a new contributor is found. Thank you for understanding 🙂

github-actions[bot] avatar Jul 14 '25 06:07 github-actions[bot]