-
Notifications
You must be signed in to change notification settings - Fork 3
/
vf-os.sh
executable file
·354 lines (324 loc) · 11 KB
/
vf-os.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#!/bin/bash
#
# Run docker-compose in a container, modified for vf-OS by including our initial compose-file.
#
# This script will attempt to mirror the host paths by using volumes for the
# following paths:
# * $(pwd)
# * $(dirname $COMPOSE_FILE) if it's set
# * $HOME if it's set
#
# You can add additional volumes (or any docker run options) using
# the $COMPOSE_OPTIONS environment variable.
#
set -e
#set -o xtrace
shopt -s nullglob
#SET TO TRUE and MODIFY DOMAIN/EMAIL for https
USE_HTTPS=/bin/false
#ACME_DOMAIN_NAME="35.181.109.46.nip.io"
ACME_DOMAIN_NAME="localhost"
ACME_EXTERNAL_IP=127.0.0.1
ACME_EMAIL="[email protected]"
CURRENT_DIR=$(pwd)
if command -v cygpath &> /dev/null; then CURRENT_DIR=`cygpath -aw $(pwd)`; fi
INITIAL_COMPOSE_FILE="0_platform_compose.yml"
NETWORK_COMPOSE_FILE="1_networks_compose.yml"
DOCKER_COMPOSE_ALIAS="docker-compose"
PROJECTNAME="vfos"
PERSISTENT_VOLUME="/persist"
mkdir -p .control_build
cd .control_build
cat << EOF > Dockerfile
FROM docker/compose:1.23.2
RUN apk --no-cache add dumb-init
ENTRYPOINT ["/usr/bin/dumb-init", "-c"]
CMD ["cat","/dev/stdout"]
EOF
docker build . -t vfos/control
cd ../
mkdir -p .compose
# Repair old version of the config files:
for file in .compose/3_*.yml; do
# Repair old version of the config files:
sed -e 's/version: \"3\"/version: \"3.4\"/' -i $file
done
mkdir -p .persist
mkdir -p .persist/aim_persist
chown -R 1000:1000 ./.persist/aim_persist
if $USE_HTTPS; then
if [ ! -e ./.persist/acme.json ]; then
touch ./.persist/acme.json
chmod 600 ./.persist/acme.json
fi
TRAEFIK_CMDLINE="--api --docker --docker.watch=true --docker.domain=$ACME_DOMAIN_NAME --defaultentrypoints=https,http --entryPoints='Name:https Address::443 TLS' --entryPoints='Name:http Address::80' --entryPoints='Name:che Address::8081' --acme --acme.storage=/acme.json --acme.entryPoint=https --acme.httpChallenge.entryPoint=http --acme.onHostRule=false --acme.onDemand=true --acme.email=$ACME_EMAIL"
TRAEFIK_ACME="- $CURRENT_DIR/.persist/acme.json:/acme.json"
else
TRAEFIK_CMDLINE="--api --docker --docker.watch=true --defaultentrypoints=http --entryPoints='Name:http Address::80' --entryPoints='Name:che Address::8081'"
fi
cat << EOF > .compose/$INITIAL_COMPOSE_FILE
version: '3.4'
services:
reverse-proxy:
image: traefik:1.7.18 # Stick to the latest 1.X version, 2.0/latest is wholly incompatible.
restart: "unless-stopped"
command: "$TRAEFIK_CMDLINE"
ports:
- "8080:8080"
- "443:443"
- "80:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
$TRAEFIK_TOML
$TRAEFIK_ACME
networks:
- default
- execution-manager-net
- system-dashboard-net
registry:
image: registry:2 #newer versions give "docker-credential-secretservice not installed or not available in PATH"
restart: "unless-stopped"
ports:
- "5000:5000" #Docker registry's can't handle subpath endpoints, need to be root-level citizen
networks:
- execution-manager-net
volumes:
- $CURRENT_DIR/.persist/registry_persist:/var/lib/registry
execution-manager:
image: localhost:5000/vfos/exec-manager
restart: "unless-stopped"
depends_on:
- registry
labels:
- "traefik.frontend.rule=PathPrefixStrip:/executionservices"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $CURRENT_DIR/.compose:/var/run/compose
- $CURRENT_DIR/.persist/executionservices_persist:$PERSISTENT_VOLUME
- $CURRENT_DIR/.persist/:/allPersist
environment:
- DOCKER_COMPOSE_PATH=/var/run/compose
- HOST_PWD=$CURRENT_DIR
networks:
- execution-manager-net
aim:
image: localhost:5000/vfos/aim
restart: "unless-stopped"
depends_on:
- registry
command: ["-b", "0.0.0.0","-Dkeycloak.profile.feature.docker=enabled", "-Dkeycloak.migration.action=import", "-Dkeycloak.migration.provider=singleFile", "-Dkeycloak.migration.file=/opt/jboss/vf-OS-realm.json", "-Dkeycloak.migration.strategy=OVERWRITE_EXISTING"]
environment:
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=vf-OS-test
- PROXY_ADDRESS_FORWARDING=true
networks:
- execution-manager-net
volumes:
- $CURRENT_DIR/.persist/aim_persist:/opt/jboss/keycloak/standalone/data
- $CURRENT_DIR/aim/vf-OS-realm.json:/opt/jboss/vf-OS-realm.json
labels:
- "traefik.frontend.rule=PathPrefix:/aim"
- "traefik.frontend.priority=-1"
- "traefik.port=8080"
- "traefik.docker.network=execution-manager-net"
deployment:
image: localhost:5000/vfos/deploy
restart: "unless-stopped"
depends_on:
- registry
- execution-manager
privileged: true
labels:
- "traefik.frontend.rule=PathPrefixStrip:/deployment"
- "traefik.frontend.priority=-1"
networks:
- execution-manager-net
volumes:
- $CURRENT_DIR/.persist/deployment_persist:$PERSISTENT_VOLUME
portal:
image: localhost:5000/vfos/portal
restart: "unless-stopped"
depends_on:
- registry
labels:
- "traefik.frontend.rule=PathPrefix:/"
- "traefik.frontend.priority=-1"
networks:
- execution-manager-net
dashboard:
image: localhost:5000/vfos/system-dashboard
restart: "unless-stopped"
depends_on:
- registry
labels:
- "traefik.frontend.rule=PathPrefixStrip:/systemdashboard"
- "traefik.frontend.priority=-1"
networks:
- system-dashboard-net
testserver:
image: localhost:5000/vfos/test-server
restart: "unless-stopped"
depends_on:
- registry
labels:
- "traefik.frontend.rule=PathPrefixStrip:/testserver"
volumes:
- $CURRENT_DIR/testImages:/usr/src/app/static
networks:
- execution-manager-net
packager:
image: localhost:5000/vfos/packaging
restart: "unless-stopped"
labels:
- "traefik.frontend.rule=PathPrefixStrip:/packaging"
environment:
- DOCKER_COMPOSE_PATH=/var/run/compose
- HOST_PWD=$CURRENT_DIR
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $CURRENT_DIR/.compose:/var/run/compose
- $CURRENT_DIR/.persist/che_data:/data
depends_on:
- registry
- execution-manager
networks:
- execution-manager-net
che:
image: cmsvfos/studio:latest
# image: hub.caixamagica.pt/vfos/studio:nightly
restart: "unless-stopped"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $CURRENT_DIR/.persist/che_data:/data
- $CURRENT_DIR/.persist/che_conf:/conf
- $CURRENT_DIR/.persist/che_logs:/logs
network_mode: host
environment:
- CHE_SINGLE_PORT=true
- CHE_PORT=8081
- CHE_HOST=$ACME_DOMAIN_NAME
- CHE_DOCKER_IP_EXTERNAL=$ACME_EXTERNAL_IP
- CHE_WORKSPACE_STORAGE=$CURRENT_DIR/.persist/che_data/workspaces/
# - CHE_INFRA_DOCKER_URL__REWRITER=singleport
- CHE_REGISTRY_HOST=172.17.0.1
labels:
- vf-OS=true
- vf-OS.name=vf-Studio
- "vf-OS.description=The vf-OS Studio, an IDE and toolchain for developing Apps and vf-OS Assets"
- vf-OS.frontendUri=http://$ACME_DOMAIN_NAME:8081/
- "traefik.enable=true"
- "traefik.frontend.entryPoints=che"
- "traefik.port=8081"
frontend_editor:
image: gklasen/vfos_frontend_editor:latest
restart: "unless-stopped"
labels:
- "traefik.main.frontend.rule=PathPrefix:/frontend_editor"
- "traefik.main.port=80"
- "traefik.iframe.frontend.rule=PathPrefix:/frontend_iframe"
- "traefik.iframe.port=4201"
networks:
- execution-manager-net
environment:
- ASSET_NAME=frontend_editor
- WORKSPACE=hello_vfos
processapi:
image: informationcatalyst/vfos-process-api
hostname: processapi
labels:
- vf-OS=true
- "traefik.frontend.rule=PathPrefixStrip:/processapi"
- "traefik.main.port=5000"
environment:
- RUN_TYPE=processapi
- CorsOrigins="http://$ACME_DOMAIN_NAME"
- "DatabaseStorageSettings__Address=mongodb://processdb:27017"
- StorageType=database
# - StorageType=remote
# - RemoteStorageSettings__Address=https://icemain2.hopto.org:7080
- MarketplaceSettings__Address=https://vfos-datahub.ascora.de/v1
- StudioSettings__Address=http://172.17.0.1:8081/
depends_on:
- processdb
processdesigner:
image: informationcatalyst/vfos-process-designer
hostname: processdesigner
labels:
- vf-OS=true
- vf-OS.description="Process Designer allows you to visually write NodeJS code"
- "traefik.frontend.rule=PathPrefixStrip:/processdesigner"
environment:
- "RUN_TYPE=processdesigner"
- "API_END_POINT=http://$ACME_DOMAIN_NAME/processapi"
depends_on:
- processapi
processdb:
image: mongo:latest
volumes:
- $CURRENT_DIR/.persist/processdb_persist:/data/db
labels:
- "traefik.frontend.rule=PathPrefix:/processdb;ReplacePathRegex: ^/processdb/(.*) /$$1"
idm:
image: localhost:5000/vfos/idm
hostname: idm
environment:
- IDM_DB_HOST=security_mysql
depends_on:
- security_mysql
networks:
- execution-manager-net
security_mysql:
image: mysql:5.7.25
hostname: security_mysql
environment:
- "MYSQL_ALLOW_EMPTY_PASSWORD=true"
volumes:
- $CURRENT_DIR/security/mysql/data:/var/lib/mysql
- type: bind
target: /etc/my.cnf
source: $CURRENT_DIR/security/mysql/etc/my.cnf
networks:
- execution-manager-net
EOF
#Setup basic network configuration
./assignNetwork.js
# Setup options for connecting to docker host
if [ -z "$DOCKER_HOST" ]; then
DOCKER_HOST="/var/run/docker.sock"
fi
if [ -S "$DOCKER_HOST" ]; then
DOCKER_ADDR="-v $DOCKER_HOST:$DOCKER_HOST -e DOCKER_HOST"
else
DOCKER_ADDR="-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH"
fi
# Only allocate tty if we detect one
if [ -t 1 ]; then
DOCKER_RUN_OPTIONS="-t"
fi
if [ -t 0 ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i"
fi
#Initial startup:
cat << EOF > .compose/$DOCKER_COMPOSE_ALIAS
#!/bin/sh
/usr/local/bin/docker-compose -p $PROJECTNAME \`ls -1 /compose/*.yml | sed -e 's/^/-f /' | tr '\n' ' '\` \$@
EOF
chmod +x .compose/$DOCKER_COMPOSE_ALIAS
COMPOSE_OPTIONS="$COMPOSE_OPTIONS -e PATH=.:/compose:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
VOLUMES="-v $CURRENT_DIR/.compose:/compose"
docker run --detach --name vf_os_platform_exec_control --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES vfos/control &
until `docker ps | grep -q "vf_os_platform_exec_control"` && [ "`docker inspect -f {{.State.Running}} vf_os_platform_exec_control`"=="true" ]; do
sleep 0.1;
done;
#Start registry
docker exec vf_os_platform_exec_control docker-compose up --no-recreate --remove-orphans -d registry &
until `docker ps | grep -q "vfos_registry_1"` && [ "`docker inspect -f {{.State.Running}} vfos_registry_1`"=="true" ]; do
sleep 0.1;
done;
if [[ "$1" == "dev" ]]; then
#Only start the registry, for building support
echo "Started registry."
else
#Start everything
docker exec vf_os_platform_exec_control docker-compose up --no-recreate --remove-orphans -d ;
fi