It’s not OK to hardcode user and password values into config, so I want to use the environment variables to pass the values. What’s the correct syntax in the configuration to do that? Something like:
But are the config.development.json and/or config.production.json files required by ghost when using the env variables from docker? If so, then what is the minimum config.env.json that is required? I plan on supplying everything via docker.
Thanks.
No, you do not need even the config file as long as you can provide the minimum required parameters (database) using env vars. NCONF is smart enough to take the default values from Ghost, override it with config.env.json and env variables
I just tested this without a config.production.json file (not Docker, but local install). I just provided database connection values (tested with sqlite3 but should work the same with MySQL)
I tested both:
Providing values on the command line :
NODE_ENV=production database__connection__filename=“SQLITE_DB_FILE” database__client=“sqlite3”
You can provide env vars anyway and it should work. Once you provide the values, the rest will be set to default(url,paths,etc.). If you want to override the others, like mail__transport (default Direct),etc. feel free to do so.
But does anyone know how to specify and call environmental variables if using ghost pro? Ideally, we should be able to set env vars within the ghost admin and then reference them in the json config file. I’m not sure why we would ever want to expose our secret passwords in a public json file. I’m using a git workflow with a custom GitHub integration that re-builds the site whenever I do a commit and push to my GitHub repo. But I shouldn’t be committing files to my repo that have secret passwords. Those should be set manually inside the ghost admin, but it seems as though Ghost is telling us that the way to do this is to expose our env vars in either the config json or the package json. Anybody know what I’m talking about and can provide assistance please? Thanks!
P.s.
I suppose having a way to upload our configuration file manually within the ghost admin would work too.