-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-entrypoint.sh
executable file
·66 lines (57 loc) · 1.96 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Restart Postfix service
service postfix restart
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
file_env 'IDM_SESSION_SECRET'
file_env 'IDM_ENCRYPTION_KEY'
file_env 'IDM_DB_PASS'
file_env 'IDM_DB_USER'
file_env 'IDM_ADMIN_ID'
file_env 'IDM_ADMIN_USER'
file_env 'IDM_ADMIN_EMAIL'
file_env 'IDM_ADMIN_PASS'
file_env 'IDM_EX_AUTH_DB_USER'
file_env 'IDM_EX_AUTH_DB_PASS'
file_env 'IDM_DB_HOST'
if [[ $IDM_SESSION_SECRET == "nodejs_idm" ]] || [[ IDM_ENCRYPTION_KEY == "nodejs_idm'" ]]; then
echo "***********************************************"
echo "WARNING: Encryption keys must be changed if you are using the IDM in a production Environment"
echo "These keys should be set using Docker Secrets"
echo "***********************************************"
fi
if [[ $IDM_DB_PASS == "idm" ]] && [[ $IDM_DB_USER == "root" ]]; then
echo "***********************************************"
echo "WARNING: It is recommended that you reconfigure the IDM database access not to use default values"
echo "These keys should be set using Docker Secrets"
echo "***********************************************"
fi
# Wait until database container is deployed
until nc -z -v -w30 $IDM_DB_HOST ${IDM_DB_PORT:-3306} > /dev/null 2>&1
do
echo "Waiting for database connection..."
# wait for 2 seconds before check again
sleep 2
done
# Check if database is created, migrated and seeded
node extras/docker/config_database.js
npm run debug_contianer