This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.sh
executable file
·98 lines (87 loc) · 1.92 KB
/
manage.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
#APPNAME=$(basename $(pwd -P))
APPNAME=imagemanager
CONTAINER_BASE=$APPNAME
CONTAINER_BASE=$(basename $(pwd -P))
TAG=base-im
PGUSER=$USER
DBUSER=willwork
set -eu
cd $(dirname $0)
usage () {
echo Usage: $0 command
echo ''
echo Read the source for the available commands
}
cleardb () {
docker exec -it ${APPNAME}_db_1 \
psql -U $DBUSER starter -c 'delete from image;'
}
clearcache () {
docker exec -it ${APPNAME}_web_1 \
sh -c 'rm -f /uploads/* /thumbnails/*'
}
if [ $# != 1 ]; then
usage >&2
exit 1
fi
case "$1" in
clear-db)
cleardb
;;
clear-cache)
clearcache
;;
clear-all)
cleardb
clearcache
;;
rebuild-client)
(cd app/client && npm run build)
;;
install-client)
(cd app/${APPNAME}/client && ./postbuild.sh)
;;
install-client-deps)
(cd app/${APPNAME}/client && npm install)
;;
rebuild-server)
docker build app -t $TAG
;;
rebuild-release)
(cd app/${APPNAME}/ && rebar3 release)
;;
start-server)
docker-compose up
;;
restart-server)
docker-compose down
docker-compose up
;;
stop-server)
docker-compose down
;;
erlang-console)
docker-compose exec web /${APPNAME}/bin/${APPNAME} remote_console
;;
shell)
docker-compose exec web sh
;;
psql)
docker-compose exec db psql -U $DBUSER starter
;;
refresh-schema)
docker-compose down || true
docker volume rm ${CONTAINER_BASE}_db
docker-compose up
;;
*)
echo No commands currently implemented
;;
esac
exit
## NOTES
# this ${APPNAME} needs to match the name repeatedly used in the Dockerfile
rebar3 new release ${APPNAME}
# postgres connection environment details need to plumbed deliberately
# e.g., using db.env