-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.sh
More file actions
executable file
·195 lines (162 loc) · 4.73 KB
/
app.sh
File metadata and controls
executable file
·195 lines (162 loc) · 4.73 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
app=$K_NAMESPACE
approot="$K_LOCALDIR"
HELP="
Run local app $app
USAGE
app command args
Commands
up - start pure3d (press Ctrl-C twice to stop)
down - stop pure3d (mostly not needed)
browse - go to local pure3d website
browse prod - go to production pure3d website
browse code - go to github repo of the source code
mongo - open mongosh (on the host) to operate on the pure3d databases
sh - open a shell in the author container
shpub - open a shell in the publishing container
build - build the pure3d docker image (for production)
buildlocal - build the pure3d docker image (for developers)
buildexportdb - build the docker image for exporting the pure3d databases (on a crontab)
push - push the pure3d docker (production) image to the registry
pushexportdb - push the docker image for exporting the pure3d databases to the registry
"
cd $approot
source .env
function apphost {
# rdctl start --application.start-in-background --virtual-machine.memory-in-gb 6
docker desktop start
}
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 appsh {
# shell into the running authoring app locally
docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -it ${app}_author /bin/bash -l
}
function appshpub {
# shell into the running publishing 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 appbuildexportdb {
# build the exportdb image
./build-exportdb.sh "$@"
}
function appbuildlocal {
# build the main image for local usage
./build-local.sh "$@"
}
function appbuild {
# build the main image for k8s
./build.sh "$@"
}
function apppushexportdb {
# push the exportdb image
./push-exportdb.sh "$@"
}
function apppush {
# push the main image for kubernetes
./push.sh "$@"
}
function appbrowse {
source .env
if [[ "$1" == "" ]]; then
echo open http://localhost:$flaskport
open http://localhost:$flaskport
elif [[ "$1" == "prod" ]]; then
echo "open https://author.pure3d.eu"
open https://author.pure3d.eu
elif [[ "$1" == "code" ]]; then
echo "open https://github.com/CLARIAH/pure3dx"
open https://github.com/CLARIAH/pure3dx
else
echo "Unknown parameter $1"
echo "Omit it or choose code"
fi
}
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 "$@"