boilerplate-nestjs-api-crud/image_files/fsroot/docker-entrypoint.d/30-prepare-env.sh
2023-04-17 10:20:39 +08:00

33 lines
1.1 KiB
Bash

# #############################################################################
# Docker Entrypoint scipt - Prepare Application Enviroment
# #############################################################################
export PORT=${APP_PORT:-3000}
# ----- Setup the Environment
if [ "${ENABLE_DUMMY_DAEMON}" = "true" ]; then
# Assume it is a development environment if ENABLE_DUMMY_DAEMON=true
export APP_ENV="development"
export NODE_ENV="development"
export LOG_LEVEL="debug"
else
# Starting as normal, so it should not be a development environment
# It should be a service for Production, UAT, or even demo
export APP_ENV=${APP_ENV:-production}
# Because of the Price Logging framework does not support setting
# the JSON format explicitly, we have to set NODE_ENV="production"
# in order to log in JSON format. Even it should be set to "development"
export NODE_ENV="production"
if [ \( -z "${LOG_LEVEL}" \) -o \( "${LOG_LEVEL}" = "" \) ]; then
if [ "${APP_ENV}" = "production" ]; then
export LOG_LEVEL="info"
else
export LOG_LEVEL="debug"
fi
fi
fi