-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker-entrypoint.sh
executable file
·49 lines (40 loc) · 1.9 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
43
44
45
46
47
48
#!/bin/bash -x
set -e
set -i
env
#### ---- Make sure to provide Non-root user for launching Docker ----
#### ---- Default, we use base images's "developer" ----
NON_ROOT_USER=${NON_ROOT_USER:-"developer"}
#### ------------------------------------------------------------------------
#### ---- You need to set PRODUCT_EXE as the full-path executable binary ----
#### ------------------------------------------------------------------------
echo "Starting docker process daemon ..."
if [ "${PRODUCT_EXE}" == "" ]; then
PRODUCT_EXE=${PRODUCT_EXE:-echo Hello}
/bin/bash -c "${PRODUCT_EXE:-echo Hello}"
fi
#### ------------------------------------------------------------------------
#### ---- Extra line added in the script to run all command line arguments
#### ---- To keep the docker process staying alive if needed.
#### ------------------------------------------------------------------------
if [ $# -lt 1 ]; then
#### ------------------------------------------------------------------------
#### ---- You need to set PRODUCT_EXE as the full-path executable binary ----
#### ------------------------------------------------------------------------
#### **** Allow non-root users to bind to use lower than 1000 ports **** ####
USE_CAP_NET_BIND=${USE_CAP_NET_BIND:-0}
if [ ${USE_CAP_NET_BIND} -gt 0 ]; then
sudo setcap 'cap_net_bind_service=+ep' ${PRODUCT_EXE}
fi
#### 1.) Setup needed stuffs, e.g., init db etc. ....
#### (do something here for preparation)
#### 2.A) As Root User -- Choose this or 2.B --####
#### ---- Use this when running Root user ---- ####
exec ${PRODUCT_EXE} "$@"
#### 2.B) As Non-Root User -- Choose this or 2.A ---- ####
#### ---- Use this when running Non-Root user ---- ####
#### ---- Use gosu (or su-exec) to drop to a non-root user
#exec gosu ${NON_ROOT_USER} ${PRODUCT_EXE} "$@"
else
exec "$@";
fi