container-env v1.0.2
container-env
An environment variable management tool for Node.js apps running inside containers
Installation
npm install container-envor globally:
npm install container-env --globalor run it with npx:
npx container-envUsage
You need to create a container-env.json file. The cli can help you with this. After the installation it is available by typing container-env or by using the alias cenv.
Create a config file:
container-env initAnswer the questions. All variable names will be transformed to uppercase and spaces will be replaced with underscores ( _ ).
You can then get the configuration read from the env variables like so:
import { getConfig } from "container-env";
const config = getConfig(JSON.parse(fs.readFileSync(path.join(__dirname, "../../container-env.json")).toString()));The getConfig() function takes one mandatory and one optional parameter: the first one needs to be the configuration object (you just need to read and parse the container-env.json file). You can optionally specify a path where the effective config should be saved.
Helpers
Add variables
Just type
container-env addGenerate run scripts
You can generate a docker-compose.yml or a docker run command by typing
container-env generate composeor
container-env generate runThe -s flag saves the output to a file in the current working directory.
Help
Just run
container-env helpto display all available commands and their explaination.
License
MIT