-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-entrypoint.sh
72 lines (62 loc) · 1.82 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
67
68
69
70
71
72
#!/bin/bash
file_env() {
# 3wc: Load $VAR_FILE into $VAR - useful for secrets. See
# https://medium.com/@adrian.gheorghe.dev/using-docker-secrets-in-your-environment-variables-7a0609659aab
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"
}
load_vars() {
file_env "DB_PASSWORD"
file_env "ADMIN_PASSWORD"
file_env "SESSION_KEY"
}
install_adapt() {
echo "No 'conf' dir found, running 'node install...'"
# 3wc: use `yes` to skip the dbPass and dbAuthSource prompts
yes "" | node install --install Y \
--authoringToolRepository https://github.com/adaptlearning/adapt_authoring.git \
--frameworkRepository https://github.com/adaptlearning/adapt_framework.git \
--frameworkRevision tags/v5.7.0 \
--serverPort "${PORT}" --serverName "${DOMAIN}" \
--dbHost "${DB_HOST}" --dbName "${DB_NAME}" --dbPort 27017 \
--dbUser "${DB_USER}" \
--useConnectionUri false \
--dataRoot data \
--sessionSecret "${SESSION_KEY}" --useffmpeg Y \
--useSmtp true --smtpService dummy \
--smtpConnectionUrl smtp://postfix_relay_app \
--fromAddress "${FROM_EMAIL}" \
--masterTenantName main --masterTenantDisplayName Main \
--suEmail "${ADMIN_EMAIL}" --suPassword "${ADMIN_PASSWORD}" \
--suRetypePassword "${ADMIN_PASSWORD}"
#--dbPass "$DB_PASSWORD" --dbAuthSource ""
#--smtpUsername "${SMTP_USERNAME}" --smtpPassword "${SMTP_PASSWORD}" \
}
main() {
set -eu
load_vars
if [ ! -d conf ]; then
install_adapt
fi
}
# while ! nc -z mongo 27017;
# do
# echo "wait for mongo";
# sleep 3;
# done;
sleep 10;
main
exec "$@"