-
Notifications
You must be signed in to change notification settings - Fork 29
/
develop-M1.sh
executable file
·275 lines (242 loc) · 8.68 KB
/
develop-M1.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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#!/usr/bin/env bash
#set -e
#
# Set up data folders.
#
if [ ! -d data ]; then
mkdir data
IS_INSTALLING="true"
fi
if [ ! -d data/csv ]; then
mkdir data/csv
fi
if [ ! -d data/client ]; then
mkdir data/client
fi
if [ ! -d data/archives ]; then
mkdir data/archives
fi
if [ ! -d data/client/releases ]; then
mkdir data/client/releases
fi
if [ ! -d data/client/releases/prod ]; then
mkdir data/client/releases/prod
fi
if [ ! -d data/client/releases/qa ]; then
mkdir data/client/releases/qa
fi
if [ ! -d data/client/releases/prod/apks ]; then
mkdir data/client/releases/prod/apks
fi
if [ ! -d data/client/releases/prod/dat ]; then
mkdir data/client/releases/prod/dat
fi
if [ ! -d data/client/releases/qa/dat ]; then
mkdir data/client/releases/qa/dat
fi
if [ ! -d data/client/releases/prod/pwas ]; then
mkdir data/client/releases/prod/pwas
fi
if [ ! -d data/client/releases/qa ]; then
mkdir data/client/releases/qa
fi
if [ ! -d data/client/releases/qa/apks ]; then
mkdir data/client/releases/qa/apks
fi
if [ ! -d data/client/releases/qa/pwas ]; then
mkdir data/client/releases/qa/pwas
fi
if [ ! -f data/id_rsa ]; then
echo '' > data/id_rsa
fi
if [ ! -f data/id_rsa.pub ]; then
echo '' > data/id_rsa.pub
fi
if [ ! -f data/reporting-worker-state.json ]; then
echo '{}' > data/reporting-worker-state.json
fi
if [ ! -f data/paid-worker-state.json ]; then
echo '{}' > data/paid-worker-state.json
fi
#
# Load config.
#
source ./config.defaults.sh
if [ -f "./config.sh" ]; then
source ./config.sh
else
echo "You have no config.sh. Copy config.defaults.sh to config.sh, change the passwords and try again." && exit 1;
fi
if echo "$T_MODULES" | grep mysql; then
./mysql-create-dirs.sh
fi
if echo "$T_USE_MYSQL_CONTAINER" | grep "true"; then
./mysql-start-container.sh
echo "Waiting 60 seconds for mysql container to start..."
sleep 60
./mysql-setup.sh
fi
if echo "$T_MYSQL_PHPMYADMIN" | grep "TRUE"; then
echo "Starting phpmyadmin..."
./phpmyadmin-start.sh
fi
# Set t_TAG to current branch and the hash for the current commit in Git
if [ "$1" = "" ]; then
if [ "$T_TAG" = "" ]; then
# T_TAG=$(git describe --tags --abbrev=0)
T_TAG=$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD)
else
T_TAG="$T_TAG"
fi
else
T_TAG="$1"
fi
echo "Setting T_TAG to: $T_TAG"
T_COUCHDB_ENDPOINT="http://$T_COUCHDB_USER_ADMIN_NAME:$T_COUCHDB_USER_ADMIN_PASS@couchdb:5984/"
export DOCKER_DEFAULT_PLATFORM=linux/arm64
#docker build -f ./Dockerfile-M1 -t tangerine/tangerine:local .
docker build --platform linux/arm64 -t tangerine/tangerine:local .
[ "$(docker ps | grep $T_CONTAINER_NAME)" ] && docker stop $T_CONTAINER_NAME
[ "$(docker ps -a | grep $T_CONTAINER_NAME)" ] && docker rm $T_CONTAINER_NAME
if [ ! -d data/couchdb ]; then
mkdir data/couchdb
fi
if [ ! -d data/couchdb/data ]; then
mkdir data/couchdb/data
fi
if [ ! -d data/couchdb/local.d ]; then
mkdir data/couchdb/local.d
fi
if [ ! -f data/couchdb/local.d/local.ini ]; then
echo "
[chttpd]
bind_address = any
[httpd]
bind_address = any
[couch_httpd_auth]
require_valid_user = true
[chttpd]
require_valid_user = true
" > data/couchdb/local.d/local.ini
fi
[ "$(docker ps | grep $T_COUCHDB_CONTAINER_NAME)" ] && docker stop $T_COUCHDB_CONTAINER_NAME
[ "$(docker ps -a | grep $T_COUCHDB_CONTAINER_NAME)" ] && docker rm $T_COUCHDB_CONTAINER_NAME
echo "Re-arranging Couchdb deck chairs. "
docker run -d \
-e COUCHDB_USER=$T_COUCHDB_USER_ADMIN_NAME \
-e COUCHDB_PASSWORD=$T_COUCHDB_USER_ADMIN_PASS \
-p 5984:5984 \
-v $(pwd)/data/couchdb/data:/opt/couchdb/data \
-v $(pwd)/data/couchdb/local.d:/opt/couchdb/etc/local.d \
--name $T_COUCHDB_CONTAINER_NAME \
couchdb:2
sleep 10
echo "Couchdb is all sorted."
#
# Start Tangerine.
#
#if [ -x "$(command -v say)" ]; then
# say 'go go gadget tangerine'
#fi
OPTIONS="--link $T_COUCHDB_CONTAINER_NAME:couchdb \
-e T_COUCHDB_ENDPOINT=\"$T_COUCHDB_ENDPOINT\" \
-e T_COUCHDB_USER_ADMIN_NAME=$T_COUCHDB_USER_ADMIN_NAME \
-e T_COUCHDB_USER_ADMIN_PASS=$T_COUCHDB_USER_ADMIN_PASS \
--entrypoint=\"/tangerine/entrypoint-development.sh\" \
--env \"NODE_ENV=development\" \
--env \"T_VERSION=$T_TAG\" \
--env \"T_PROTOCOL=$T_PROTOCOL\" \
--env \"T_UPLOAD_TOKEN=$T_UPLOAD_TOKEN\" \
--env \"T_USER1=$T_USER1\" \
--env \"T_USER1_PASSWORD=$T_USER1_PASSWORD\" \
--env \"T_HOST_NAME=$T_HOST_NAME\" \
--env \"T_USER1_MANAGED_SERVER_USERS=$T_USER1_MANAGED_SERVER_USERS\" \
--env \"T_PAID_ALLOWANCE=$T_PAID_ALLOWANCE\" \
--env \"T_PAID_MODE=$T_PAID_MODE\" \
--env \"T_REPORTING_DELAY=$T_REPORTING_DELAY\" \
--env \"T_CSV_BATCH_SIZE=$T_CSV_BATCH_SIZE\" \
--env \"T_HIDE_PROFILE=$T_HIDE_PROFILE\" \
--env \"T_MODULES=$T_MODULES\" \
--env \"T_CORS_ALLOWED_ORIGINS=$T_CORS_ALLOWED_ORIGINS\" \
--env \"T_AUTO_COMMIT=$T_AUTO_COMMIT\" \
--env \"T_AUTO_COMMIT_FREQUENCY=$T_AUTO_COMMIT_FREQUENCY\" \
--env \"T_LEGACY=$T_LEGACY\" \
--env \"T_REGISTRATION_REQUIRES_SERVER_USER=$T_REGISTRATION_REQUIRES_SERVER_USER\" \
--env \"T_CENTRALLY_MANAGED_USER_PROFILE=$T_CENTRALLY_MANAGED_USER_PROFILE\" \
--env \"T_CATEGORIES=$T_CATEGORIES\" \
--env \"T_ORIENTATION=$T_ORIENTATION\" \
--env \"T_REPORTING_MARK_OPTIONAL_NO_ANSWER_WITH=$T_REPORTING_MARK_OPTIONAL_NO_ANSWER_WITH\" \
--env \"T_REPORTING_MARK_DISABLED_OR_HIDDEN_WITH=$T_REPORTING_MARK_DISABLED_OR_HIDDEN_WITH\" \
--env \"T_REPORTING_MARK_SKIPPED_WITH=$T_REPORTING_MARK_SKIPPED_WITH\" \
--env \"T_REPORTING_MARK_UNDEFINED_WITH=$T_REPORTING_MARK_UNDEFINED_WITH\" \
--env \"T_HIDE_SKIP_IF=$T_HIDE_SKIP_IF\" \
--env \"T_NGROK_AUTH_TOKEN=$T_NGROK_AUTH_TOKEN\" \
--env \"T_NGROK_SUBDOMAIN=$T_NGROK_SUBDOMAIN\" \
--env \"T_ARCHIVE_APKS_TO_DISK=$T_ARCHIVE_APKS_TO_DISK\" \
--env \"T_ARCHIVE_PWAS_TO_DISK=$T_ARCHIVE_PWAS_TO_DISK\" \
--env \"T_PASSWORD_POLICY=$T_PASSWORD_POLICY\" \
--env \"T_PASSWORD_RECIPE=$T_PASSWORD_RECIPE\" \
--env \"T_CUSTOM_LOGIN_MARKUP=$T_CUSTOM_LOGIN_MARKUP\" \
--env \"T_JWT_ISSUER=$T_JWT_ISSUER\" \
--env \"T_JWT_EXPIRES_IN=$T_JWT_EXPIRES_IN\" \
--env \"T_ONLY_PROCESS_THESE_GROUPS=$T_ONLY_PROCESS_THESE_GROUPS\" \
--env \"T_LIMIT_NUMBER_OF_CHANGES=$T_LIMIT_NUMBER_OF_CHANGES\" \
$T_PORT_MAPPING \
-p 9229:9229 \
-p 9228:9228 \
-p 9227:9227 \
-p 9226:9226 \
-p 9225:9225 \
--volume $(pwd)/data/groups:/tangerine/groups/:delegated \
--volume $(pwd)/data/csv:/csv/:delegated \
--volume $(pwd)/data/archives:/archives/:delegated \
--volume $(pwd)/data/reporting-worker-state.json:/reporting-worker-state.json:delegated \
--volume $(pwd)/data/paid-worker-state.json:/paid-worker-state.json:delegated \
--volume $(pwd)/data/client/releases:/tangerine/client/releases/:delegated \
--volume $(pwd)/data/client/content/groups:/tangerine/client/content/groups:delegated \
--volume $(pwd)/data/client/content/assets:/tangerine/client/content/assets:delegated \
--volume $(pwd)/content-sets:/tangerine/content-sets:delegated \
--volume $(pwd)/server/package.json:/tangerine/server/package.json:delegated \
--volume $(pwd)/server/src:/tangerine/server/src:delegated \
--volume $(pwd)/client/src:/tangerine/client/src:delegated \
--volume $(pwd)/client/dist:/tangerine/client/dist:delegated \
--volume $(pwd)/server/reporting:/tangerine/server/reporting:delegated \
--volume $(pwd)/upgrades:/tangerine/upgrades:delegated \
--volume $(pwd)/scripts/generate-csv/bin.js:/tangerine/scripts/generate-csv/bin.js:delegated \
--volume $(pwd)/scripts/generate-csv/batch.js:/tangerine/scripts/generate-csv/batch.js:delegated \
--volume $(pwd)/data/id_rsa:/root/.ssh/id_rsa:delegated \
--volume $(pwd)/data/id_rsa.pub:/root/.ssh/id_rsa.pub:delegated \
--volume $(pwd)/editor/src:/tangerine/editor/src:delegated \
--volume $(pwd)/translations:/tangerine/translations:delegated \
--volume $(pwd)/online-survey-app/src:/tangerine/online-survey-app/src:delegated \
--volume $(pwd)/server/phantomjs-1.9.8-linux-x86_64.tar.bz2:/tangerine/server/phantomjs-1.9.8-linux-x86_64.tar.bz2:delegated
tangerine/tangerine:local
"
echo "Populated OPTIONS"
if echo "$T_USE_MYSQL_CONTAINER" | grep "true"; then
echo "Linking mysql container ..."
OPTIONS="
--link $T_MYSQL_CONTAINER_NAME:mysql \
$OPTIONS
"
fi
if echo "$T_MODULES" | grep mysql; then
OPTIONS="
--env \"T_MYSQL_CONTAINER_NAME=$T_MYSQL_CONTAINER_NAME\" \
--env \"T_MYSQL_USER=$T_MYSQL_USER\" \
--env \"T_MYSQL_PASSWORD=$T_MYSQL_PASSWORD\" \
--env \"T_MYSQL_MULTI_PARTICIPANT_SCHEMA=$T_MYSQL_MULTI_PARTICIPANT_SCHEMA\" \
--volume $(pwd)/data/mysql/state:/mysql-module-state:delegated \
$OPTIONS
"
fi
function trapperkeeper {
echo "Exiting - Tangerine has stopped."
}
trap trapperkeeper EXIT
echo "About to run the container."
#--platform linux/arm64
CMD="docker run -it --name $T_CONTAINER_NAME \
$OPTIONS
"
eval ${CMD}