node/docker-entrypoint.sh
2024-02-11 04:13:58 +01:00

38 lines
898 B
Bash
Executable file

#!/bin/bash
export IP=$( hostname -i )
cat <<EOF
__ _
___ _ ____ __ / / _ __ ___ __| | ___
/ __| '__\ \ / / / / | '_ \ / _ \ / _\` |/ _ \\
\__ \ | \ V / / / | | | | (_) | (_| | __/
|___/_| \_/ /_/ |_| |_|\___/ \__,_|\___|
------------------------------------------------
IP: $IP
EOF
if [[ ! -d "node_modules" ]]; then
echo "node_modules does not exist."
if [[ -f "package.json" ]]; then
npm install
fi
fi
if [[ -z "$@" ]]; then
if [[ -f "package.json" ]]; then
PACKAGE_JSON_START=$( cat package.json | jq -r '.scripts.start // empty' )
if [[ -z "$PACKAGE_JSON_START" ]]; then
echo "package.json found, but no start script, starting bash..."
exec bash
else
exec $PACKAGE_JSON_START
fi
else
echo "No package.json found, starting bash..."
exec bash
fi
else
exec $@
fi