-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-entrypoint.sh
75 lines (63 loc) · 1.49 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
73
74
75
#!/bin/bash
command=${1:-api}
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if [ -z "$ARA_DB_PASSWORD" ]; then
echo "No database password defined by ARA_DB_PASSWORD"
exit 1
fi
if [ -z "$ARA_API_KEY" ]; then
echo "No api key defined by ARA_API_KEY"
exit 1
fi
if [ -n "$GCLOUD_KEYFILE_JSON" ]; then
export GOOGLE_APPLICATION_CREDENTIALS="gcloud-keyfile.json"
echo -En "$GCLOUD_KEYFILE_JSON" > "$GOOGLE_APPLICATION_CREDENTIALS"
unset GCLOUD_KEYFILE_JSON
fi
cat > config/database.yml <<EOF
${ARA_ENV:-production}:
name: ${ARA_DB_NAME:-ara}
user: ${ARA_DB_USER:-ara}
host: ${ARA_DB_HOST:-db}
password: ${ARA_DB_PASSWORD}
port: ${ARA_DB_PORT:-5432}
EOF
# echo "Current database config"
# echo "---"
# cat config/database.yml
# echo "---"
cat > config/config.yml <<EOF
syslog: ${ARA_SYSLOG:-false}
debug: ${ARA_DEBUG:-false}
apikey: ${ARA_API_KEY}
bigqueryprojectid: ${GCLOUD_PROJECT}
bigquerydatasetprefix: ${BIGQUERY_DATASET_PREFIX}
EOF
if [ -n "$SENTRY_DSN" ]; then
echo "sentry: ${SENTRY_DSN}" >> config/config.yml
fi
# echo "Current Ara config"
# echo "---"
# cat config/config.yml
# echo "---"
touch config/production.yml
echo "Start $command"
case $command in
api)
if [ "$RUN_MIGRATIONS" = "true" ]; then
./ara migrate up || exit $?
fi
exec ./ara api -listen 0.0.0.0:8080
;;
shell)
exec bash
;;
migrate)
exec ./ara migrate up
;;
purge)
exec ./ara purge -days 3
;;
*)
exec $@
esac