forked from expertiza/expertiza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_entrypoint.sh
executable file
·50 lines (39 loc) · 1.75 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
#!/bin/sh
if [ ! -f .initialized ]; then
echo "Initializing container"
cp /app/config/secrets.yml.example /app/config/secrets.yml
# Remove default development configuration
sed '7,9d' ./config/database.yml.example > ./config/database.yml
echo "development:
adapter: mysql2
host: mysql
username: root
password: expertiza
database: expertiza_production" >> ./config/database.yml
# Begin to mount
echo "Inserting scrubbed db into database... this may take awhile!"
mysql --user=root --password=expertiza --host=mysql expertiza_production < /app/expertiza.sql
if [ $? -ne 0 ]; then
echo "Failed to import db"
rm -rf /app/expertiza-db
exit 1
fi
# run initializing commands
eval 'bundle exec rake db:migrate RAILS_ENV=development'
if [ $? -eq 0 ]; then
touch .initialized
echo "Migrations success!"
else
echo "Failed migrations"
rm -rf /app/expertiza-db
exit 1
fi
fi
set -e
if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi
echo "bundle exec rails s -b 0.0.0.0" > /app/docker-start.sh
chmod +x /app/docker-start.sh
echo "Expertiza container started"
/bin/sh -c "while sleep 1000; do :; done"