Open facekapow opened 7 years ago
Yeah, great idea!
I think passing env variables through command line is the best option. So the same initrd bundle can be used in different environments (development/production etc). runtime.js should probably not expose raw command line to the app, and we can remove --append
option as well.
Running something like this:
runtime start -ENODE_ENV=production -ESECURE_KEY=abc
can internally do this:
runtime start --append={"env":{"NODE_ENV":"production","SECURE_KEY":"abc"}}
This was brought to my attention by @aafrey on Gitter.
This is already kind of possible by using kernel command line arguments (
--append
and__SYSCALL.getCommandLine()
), but it's neither officially supported nor elegant.Why?
How to pass them in?
runtime-cli
runtime.json
Problems with each implementation:
runtime.json
: if you.gitignore
it so that you don't accidentally leak the variables, you're also gitignoring a file that might contain settings you do want to commit (e.g. v8.flags)Possible solution:
Implement both? That way, you can make unimportant variables persistent by adding them to
runtime.json
, while keeping ultimately secret variables as arguments.How to get them?
Well,
process.env
!