I'm deploying my node.js app, which is based on Ghost, on Google Compute Engine. However, I'm not sure whether it is a good behavior to write my database credentials in config.js
.
The config.js
file is something like the follows:
...
'production': {
url: 'http://127.0.0.1:2368',
database: {
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'root',
password : 'root',
database : 'ghost',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2368'
},
},...
However, this includes the database credentials hard-coded in config.js
. I'm not sure if this is secure enough in production.
Should I be better off to set the credentials using environment variables from process.env.xxx
(e.g. process.env.DB_USER
)? In that case, what is the best way to write those environment variables in a file and run the app with the configuration?