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

37 lines
1.1 KiB
Bash

#!/bin/sh
# This script use sh. Since the sh may be different function in distributions.
# In order to make the maximum compatibility, please use classic technique.
# Example, if-condition, 'source' command.
# Exit immediately if a command exits with a non-zero status.
set -e
# (same as set -o errexit)
# The condition use classic technique
if [ \( "${LOG_IN_JSON_FMT}" = "false" \) -o \( "${LOG_IN_JSON_FMT}" = "0" \) ]; then
unset LOG_IN_JSON_FMT
# Otherwise, other value will enable Log in JSON
fi
. /usr/local/bin/script_utils.sh
# Run (startup) scripts for the entrypoint if any:
if [ $# -eq 0 ]; then
if [ -d '/docker-entrypoint.d' ]; then
for f in /docker-entrypoint.d/*.sh; do
. "$f" "$@"
done
fi
# If daemon script does not work as daemon,
# Use the follow command to keep the container running as daemon
if [ "${ENABLE_DUMMY_DAEMON}" = "true" ]; then
logging_warning "[!] Running as dummy daemon"
tail -f /dev/null
else
# Run the shell
/bin/sh
fi
else
exec "$@"
fi