Reputation: 1140
I'm new to sails and nodejs, and trying to figure out how best to handle configuration, particularly in usage with Docker. It's been suggested to me that I maintain a separate folder with all the config files outside of the Sails application that Sails will read from before starting up the application.
Based on what I understand about Sails, I would want to bootstrap a method that would copy the config files (using fs?) from a outside directory that I store the configuration.
Is there a better way to do this?
Thanks.
Upvotes: 0
Views: 1041
Reputation: 1140
For use with Docker, I used the following model:
Before loading config, check if environment variable exists (process.env.VARIABLE), if not, read from sails config file.
Upvotes: 0
Reputation: 3174
There is a config folder generated by sails when you start a new project, isn't it a good place to store your config ?
If you use git and don't want your config to be versioned, by default, config/local.js
is in the .gitignore
.
Otherwise, using config/bootstrap.js
you can perform actions before the app lifts, such as copying config files over.
Beware, though, that the filepath you use will end up in your VCS, unless you put them in the local.js
Upvotes: 1