-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
46 lines (39 loc) · 1.05 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
export GUNICORN_APP=${GUNICORN_APP:-"insights.wsgi"}
export GUNICORN_CONF=${GUNICORN_CONF:-"${PROJECT_PATH}/gunicorn.conf.py"}
export LOG_LEVEL=${LOG_LEVEL:-"INFO"}
do_gosu(){
user="$1"
shift 1
is_exec="false"
if [ "$1" = "exec" ]; then
is_exec="true"
shift 1
fi
if [ "$(id -u)" = "0" ]; then
if [ "${is_exec}" = "true" ]; then
exec gosu "${user}" "$@"
else
gosu "${user}" "$@"
return "$?"
fi
else
if [ "${is_exec}" = "true" ]; then
exec "$@"
else
eval '"$@"'
return "$?"
fi
fi
}
if [[ "start" == "$1" ]]; then
echo "Run collectstatic"
do_gosu "${PROJECT_USER}:${PROJECT_GROUP}" python manage.py collectstatic --noinput
echo "Starting gunicorn workers"
do_gosu "${PROJECT_USER}:${PROJECT_GROUP}" exec gunicorn "${GUNICORN_APP}" \
--name="${APPLICATION_NAME}" \
--chdir="${PROJECT_PATH}" \
--bind=0.0.0.0:8000 \
-c "${GUNICORN_CONF}"
fi
exec "$@"