Appsody Environment Variables

Stack creators configure Appsody environment variables to specify the behaviour they expect from the stack throughout the application development lifecycle. These variables are defined in Dockerfile-stack for the stack image. Appsody CLI and Appsody controller inspect these environment variables and then drive the expected behaviour for the developer.

If a stack image is built upon another stack's image, it will inherit all the Appsody variables from the base stack. It can override the variables it wants to change. This allows users to create stacks with slightly different behaviour while still getting updates from the base stack.

The following are the currently supported Appsody environment variables and their default values:

Variable Description Example Default
APPSODY_WATCH_DIR This variable contains the watch directories to watch for changes in. There can be multple directories separated by a ';'. The format is dir1;dir2. The value of APPSODY_MOUNTS can be used in place of APPSODY_WATCH_DIR. ENV APPSODY_WATCH_DIR=/project/user-app N/A
APPSODY_WATCH_INTERVAL This is the watch interval (in seconds). This is optional. APPSODY_WATCH_INTERVAL = 3 2 seconds
APPSODY_WATCH_REGEX This is a regex expression which describes which files are watched for changes. Currently negative look ahead matching (e.g. ignore patterns) is not supported. ENV APPSODY_WATCH_REGEX="^.*.js$" (^..java$)|(^..js$)|(^.*.go$)
APPSODY_WATCH_IGNORE_DIR This variable contains the directories to ignore any changes in. There can be multiple directories separated by a ';'. The format is dir1;dir2. ENV APPSODY_WATCH_IGNORE_DIR=/project/user-app/node_modules N/A
APPSODY_MOUNTS This variable contains the mount directories, which can alternatively be used as watch directories if no value exists for APPSODY_WATCH_DIR. There can be multiple mount directories separated by a';'. The format is :/. ENV APPSODY_MOUNTS=/:/project/user-app N/A
APPSODY_DEPS This variable is used to cache the combined dependencies of the stack components and the user application. It is not mounted into the user directory as it is not required outside the Docker environment. ENV APPSODY_DEPS=/project/deps N/A
APPSODY_PREP This is an optional command executed before the APPSODY_RUN/TEST/DEBUG and APPSODY_RUN/TEST/DEBUG_ON_CHANGE commands are run. This command should only be used to perform prerequisite checks or preparation steps prior to starting the app server. If this command fails, APPSODY_RUN/TEST/DEBUG will not be executed and the appsody container will be terminated. It is not recommended to perform code compilation tasks in APPSODY_PREP because compilation errors can typically be fixed and recovered while the container is running with the APPSODY_RUN/TEST/DEBUG and ON_CHANGE commands. Unlike those commands, APPSODY_PREP will only be run once and never retried. Note: APPSODY_INSTALL is deprecated and has been replaced with APPSODY_PREP ENV APPSODY_PREP="npm install --prefix user-app" N/A
APPSODY_RUN This is the command run for the server process after the APPSODY_PREP command, when the mode is 'run'. If your command involves complex environment variable expansions, it may be better to encapsulate your command into a script. ENV APPSODY_RUN="npm start" N/A
APPSODY_RUN_ON_CHANGE This is the command run when a change is detected on the file system by the controller when the mode is 'run'. When APPSODY_RUN_KILL=false, this action will only be used if the application launched by APPSODY_RUN is still running. If your command involves complex environment variable expansions, it may be better to encapsulate your command into a script. If the file watching is disabled, the value should be "". ENV APPSODY_RUN_ON_CHANGE="npm start" N/A
APPSODY_RUN_KILL APPSODY_RUN_KILL is used to signal that when the mode is "run" the controller will kill the server process started by APPSODY_RUN prior to starting the watch action specified by APPSODY_RUN_ON_CHANGE. The values supported are true or false. ENV APPSODY_RUN_KILL=<true/false> true
APPSODY_DEBUG This is the command for the server process run after the APPSODY_PREP command, when the mode is 'debug'. If your command involves complex environment variable expansions, it may be better to encapsulate your command into a script. ENV APPSODY_DEBUG="npm run debug" N/A
APPSODY_DEBUG_ON_CHANGE This is the command run when a change is detected on the file system by the controller when the mode is 'debug'. When APPSODY_DEBUG_KILL=false, this action will only be used if the application launched by APPSODY_DEBUG is still running. If your command involves complex environment variable expansions, it may be better to encapsulate your command into a script. If the file watching is disabled, the value should be "". ENV APPSODY_DEBUG_ON_CHANGE="npm run debug" N/A
APPSODY_DEBUG_KILL This variable is used to signal that when the mode is "debug" the controller will kill the server process started by APPSODY_DEBUG prior to starting the watch action specified by APPSODY_DEBUG_ON_CHANGE. The values supported are true or false. APPSODY_DEBUG_KILL=<true/false> true
APPSODY_TEST This is the command to run the test cases run after the APPSODY_PREP command, when the mode is 'test'. If your command involves complex environment variable expansions, it may be better to encapsulate your command into a script. ENV APPSODY_TEST="npm test && npm test --prefix user-app" N/A
APPSODY_TEST_ON_CHANGE This is the command run when a change is detected on the file system by the controller when the mode is 'test'. When APPSODY_TEST_KILL=false, this action will only be used if the application launched by APPSODY_TEST is still running. If your command involves complex environment variable expansions, it may be better to encapsulate your command into a script. If the file watching is disabled, the value should be "". ENV APPSODY_TEST_ON_CHANGE="" N/A
APPSODY_TEST_KILL This variable is used to signal that when the mode is "test" the controller will kill the server process started by APPSODY_TEST prior to starting the watch action specified by APPSODY_TEST_ON_CHANGE. The values supported are true or false. APPSODY_TEST_KILL=<true/false> true
APPSODY_PROJECT_DIR This variable allows override of the project directory while running appsody extract, appsody build or appsody deploy. APPSODY_PROJECT_DIR=/<my-project-directory> /project