-
Notifications
You must be signed in to change notification settings - Fork 8
/
docker-entrypoint.sh
executable file
·43 lines (36 loc) · 1.22 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#
###########################################################################
#### ---- docker-entrypoint.sh: for application with ./app folder ---- ####
###########################################################################
# docker-entrypoint.sh
#
# The Dockerfile CMD, or any "docker run" command option, gets
# passed as command-line arguments to this script.
# Abort on any error (good shell hygiene)
set -e
env
echo ">>> inputs: $@"
APP_MAIN=${APP_MAIN:-setup.sh}
base_app=$(basename $APP_MAIN)
find_app_main=`find $HOME -name $base_app -print | head -n 1`
if [ "${find_app_main}" != "" ]; then
APP_MAIN=${find_app_main}
echo "--- Found the actual location of APP_MAIN: ${APP_MAIN}"
# If we're running "myAppName", provide default options
if [ "$(basename $1)" = "$(basename $APP_MAIN)" ]; then
echo ">> Running: ${APP_MAIN}"
shift 1
# Then run it with default options plus whatever else
# was given in the command
exec ${APP_MAIN} $@
tail -f /dev/null
else
# Otherwise just run what was given in the command
echo ">> Running: $@"
$@
fi
else
echo "--- APP_MAIN not found in CMD (from Dockerfile or run) ..."
$@
fi