-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·76 lines (64 loc) · 1.61 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
76
#!/bin/sh
# ------------------------------------------------------------------------------
set -e
if [ -z ${PROXY_CERT} ]
then
echo "No proxy certificate to append"
else
echo "Appending proxy certificate"
cat $PROXY_CERT >> /etc/ssl/certs/ca-certificates.crt
fi
if [ ${RAILS_ENV} != "production" ]
then
#
# Development & Test
#
# ------------------------------------------------------------------------------
if bundle check
then
echo "$RAILS_ENV gems already bundled"
else
bundle
fi
if [ ! -d "node_modules" ]
then
bundle exec rails yarn:install
fi
if [ -z ${DATABASE_URL} ]
then
echo "DATABASE_URL is not defined and cannot be prepared"
else
bundle exec rails db:create db:migrate
fi
rm -f tmp/pids/server.pid
# ------------------------------------------------------------------------------
else
#
# Production
#
# ------------------------------------------------------------------------------
if [ -z ${ENVIRONMENT} ]
then
echo "Azure ENVIRONMENT is not defined"
else
# Azure WebSSH
/usr/sbin/sshd
eval $(printenv | xargs 2>/dev/null | export > /root/.profile)
bundle exec rails db:create db:migrate
case ${ENVIRONMENT} in
"development" )
bundle exec rails db:seed eyfs:bot sitemap:refresh:no_ping
;;
"staging" )
# no op
;;
"production" )
rm public/robots.txt && touch public/robots.txt
;;
* )
echo "Azure ENVIRONMENT ${ENVIRONMENT} is not supported"
esac
fi
# ------------------------------------------------------------------------------
fi
exec bundle exec "$@"