-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprod-run-clean.sh
executable file
·65 lines (47 loc) · 1.63 KB
/
prod-run-clean.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
#!/bin/bash
die(){
echo $*
exit 2
}
# start up tapp for production
echo 'have you pulled from master appropriately?'
git status
echo
echo 'have you shut down containers already with docker down?'
echo 'examine running containers, if any in table below'
docker ps
echo
echo 'if there are any tapp containers listed above you should consider '
echo 'docker-compose down, perhaps even down -v (to remove the postgres volume)'
echo
echo '*** to really nuke the containers consider `docker system prune --all --force` ***'
echo
read -p 'hit enter to continue: [interrupt to quit]: '
read -p 'enter to cp prod.env.devfault .env :' JUNK
(set -x
cp prod.env.default .env
)
read -p 'enter to `docker-compose build` ' JUNK
(set -x
docker-compose build || die docker-compose build failed
)
read -p 'enter to `docker-compose up -d tapp containers: ' JUNK
(set -x
docker-compose up -d || die docker-compose up -d failed
)
#there is probably a race condition here. migrate can't work until container is really up.
#in production we set restart policy to be always so containers restart after reboot --
# but this causes an admin task like a migration to restart even when it exits 0
# so add another layer of composition (admin) that turns off the restart
read -p 'enter to `migrate postgres db: ' JUNK
# (set -x
# docker-compose \
# -f docker-compose.yml \
# -f docker-compose.production.yml \
# -f docker-compose.production-admin.yml \
# run rails-app rake db:migrate
# )|| die "rake db:migrate failed"
(set -x
docker-compose run rails-app rake db:migrate || die "rake db:migrate failed"
)
echo to see the log: docker-compose logs --follow