Environment variables

On NodeChef, you can either setup environment variables to be deployed with your application as well as set them from the dashboard after the app is deployed.

The platform by default sets the below list of environment variables on all your containers.

Variable Description
PORT The TCP port available to use in your container.
BIND_IP The TCP IPv4 address available to use in your container.
DATABASE_URI The connection string to your database if you created a database with your application.
DATABASE_URL The connection string to your database if you created a database with your application.
DB_USER
DB_PASSWORD
DB_HOST
DB_NAME
Specifies the database user, password, host address and name respectively.
JDBC_DATABASE_URL If you created a MySQL or PostgreSQL database, this environment variable duplicates the value of the DATABASE_URI variable.
JDBC_DATABASE_USERNAME
JDBC_DATABASE_PASSWORD
Specifies the database use and password of the JDBC connection string.
MEMORY_LIMIT The memory size of the container in megabytes. Eg: 256M
INSTANCE_INDEX If you have more than one app container, this value provides the index of this container in the list of containers. This value is a zero based index
HOME The root folder of your application.


Setting environment variables from the dashboard after your App is deployed.

To edit your environment variables from the web dashboard. Under the task manager, find your app listed and click on App actions → Environment variables. You can then modify any environment variables or include new ones.



Setting environment variables using the CLI

To setup environment variables to be deployed with your application. Create a file with an arbitrary name anywhere on your file system. For this example, this file will be named env.json. You can also name this file as env_dev.json, env_stage.json and so on.

On deployment use the -e switch to specify the name of your environment variables file.

Example env.json file

{ "SOME_API_URL": "https://this-is-just-an-example.cocm" }

Note: The env.json file should contain a simple json structure of key and string value pairs.