-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunlocal.sh
executable file
·158 lines (130 loc) · 3.61 KB
/
runlocal.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
app=$K_NAMESPACE
approot="$K_LOCALDIR"
HELP="
Run local app $app
USAGE
runlocal [host|up|down|peek|peekpub|mongo|buildlocal|build|dev] args
"
cd $approot
source .env
function apphost {
rdctl start --application.start-in-background --virtual-machine.memory-in-gb 6
}
function appup {
# start the app, including its services
apphost
flaskdebug="x"
runmode=""
good="v"
while [ ! -z "$1" ]; do
if [[ "$1" == "prod" ]]; then
runmode="prod"
shift
elif [[ "$1" == "test" ]]; then
runmode="test"
shift
elif [[ "$1" == "pilot" ]]; then
runmode="pilot"
shift
elif [[ "$1" == "custom" ]]; then
runmode="custom"
shift
elif [[ "$1" == "nodebug" ]]; then
flaskdebug="x"
shift
elif [[ "$1" == "debug" ]]; then
flaskdebug="v"
shift
else
echo "unrecognized argument '$1'"
good="x"
shift
fi
done
if [[ "$runmode" == "" ]]; then
echo "runmode not set to either prod, test, pilot, or custom"
good="x"
fi
if [[ "$good" == "v" ]]; then
export runmode
export flaskdebug
docker compose up -d
docker compose logs -f
docker compose down
fi
}
function appdown {
# stop the app, including its services (mongod)
# mostly not needed, because we end appup with Ctrl+C
docker compose down
}
function apppeek {
# shell into the running app locally
docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -it ${app}_author /bin/bash -l
}
function apppeekpub {
# shell into the running app locally
docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -it ${app}_pub /bin/bash -l
}
function appmongo {
# open the host mongo client and connect to the mongod service of the app
runmode=""
good="v"
while [ ! -z "$1" ]; do
if [[ "$1" == "prod" ]]; then
runmode="prod"
shift
elif [[ "$1" == "test" ]]; then
runmode="test"
shift
elif [[ "$1" == "pilot" ]]; then
runmode="pilot"
shift
elif [[ "$1" == "custom" ]]; then
runmode="custom"
shift
else
echo "unrecognized argument '$1'"
good="x"
shift
fi
done
if [[ "$runmode" == "" ]]; then
mongosh --port $mongoportouter -u $mongouser -p $mongopassword --authenticationDatabase admin
else
echo mongosh --port $mongoportouter -u root -p example --authenticationDatabase admin ${app}_$runmode
mongosh --port $mongoportouter -u $mongouser -p $mongopassword --authenticationDatabase admin ${app}_$runmode
fi
}
function appbuildlocal {
# build the app locally, using local github clone as is
# if you pass "push" as argument, the docker images will be pushed to the
# registry
./build-local.sh "$@"
}
function appbuild {
# build the app for kubernetes, using local github clone as is
# if you pass "push" as argument, the docker images will be pushed to the
# registry
./build.sh "$@"
}
function appdev {
# build the app on the dev machine, i.e.
# on the dev machine: clone the repo,
# and, unless "restart-only" is passed, build the docker image
# and restart the app
./start.sh "$@"
}
command="$1"
if [ -z "$1" ]; then
echo "no command given"
printf "$HELP"
exit
elif [ "$1" == "--help" ]; then
printf "$HELP"
exit
fi
command="$1"
shift
app$command "$@"