-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-entrypoint.sh
48 lines (37 loc) · 1.68 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
#!/bin/bash
set -e
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 [ $# -gt 0 ]; then
#### **** 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 "$@"
/bin/bash -c "$@"
#### 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
/bin/bash -c "${PRODUCT_EXE}";
fi