-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·96 lines (80 loc) · 2.96 KB
/
deploy
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
#!/usr/bin/env bash
set -eu
. sites
# Configure branches here
NETWORK=epimodels
APP_BRANCH=main
APP_PREVIEW=main
API_BRANCH=main
PROXY_BRANCH=main
# Nothing to change below here!
REDIS="--redis-url=redis://wodin-redis:6379"
if [[ ! -f hostname ]]; then
echo "Did not find file 'hostname' in current directory"
exit 1
fi
WODIN_HOST=$(cat hostname)
if [[ $WODIN_HOST == "localhost" ]]; then
SSL=
SSL_PORTS=
PROTOCOL="http"
else
SSL="--ssl"
SSL_PORTS="-p 443:443"
PROTOCOL="https"
fi
echo "*** Pulling images"
docker pull mrcide/odin.api:$API_BRANCH
docker pull ghcr.io/mrc-ide/wodin:$APP_BRANCH
docker pull ghcr.io/mrc-ide/wodin:$APP_PREVIEW
docker pull mrcide/wodin-proxy:$PROXY_BRANCH
docker network create $NETWORK --subnet 192.168.160.0/20 2> /dev/null || /bin/true
docker volume create redis-docker
docker volume create wodin-config
echo "*** Updating config"
SITES_ARGS=()
for SITE in "${SITES[@]}"; do
SITES_ARGS+=(/config/$SITE ${SITES_URL[$SITE]} "${SITES_REF[$SITE]:-main}")
done
docker run --rm -v wodin-config:/config --entrypoint update-sites \
ghcr.io/mrc-ide/wodin:$APP_BRANCH ${SITES_ARGS[@]}
docker run --rm -v wodin-config:/config --entrypoint update-sites \
ghcr.io/mrc-ide/wodin:$APP_PREVIEW /config/preview https://github.com/mrc-ide/wodin-demo-config "main"
echo "*** Bringing down any old containers"
docker rm --force $(docker ps -qa -f 'name=wodin-') 2> /dev/null || /bin/true
echo "*** Starting wodin"
# Shared:
docker run -d --name wodin-redis -v redis-data:/data --network=$NETWORK redis:6
docker run -d --name wodin-api --network=$NETWORK mrcide/odin.api:$API_BRANCH
PROXY_SITE_ARG=""
for SITE in "${SITES[@]}"; do
echo "Bringing up $SITE"
docker run -d --name "wodin-$SITE" --network=$NETWORK \
-v wodin-config:/wodin/config:ro \
ghcr.io/mrc-ide/wodin:$APP_BRANCH \
--redis-url=redis://wodin-redis:6379 \
--odin-api=http://wodin-api:8001 \
--base-url=$PROTOCOL://$WODIN_HOST/$SITE /wodin/config/$SITE
PROXY_SITE_ARG+="--site $SITE=wodin-$SITE:3000 "
done
echo "Bringing up preview"
docker run -d --name "wodin-preview" --network=$NETWORK \
-v wodin-config:/wodin/config:ro \
ghcr.io/mrc-ide/wodin:$APP_PREVIEW \
--redis-url=redis://wodin-redis:6379 \
--odin-api=http://wodin-api:8001 \
--base-url=$PROTOCOL://$WODIN_HOST/preview /wodin/config/preview
PROXY_SITE_ARG+="--site preview=wodin-preview:3000 "
docker run -d --network $NETWORK --name wodin-proxy \
-p 80:80 $SSL_PORTS \
-v $PWD/root:/wodin/root:ro \
mrcide/wodin-proxy:$PROXY_BRANCH \
$WODIN_HOST $SSL $PROXY_SITE_ARG
if [[ $WODIN_HOST == "localhost" ]]; then
echo "*** Not copying certificates, using http only"
else
echo "*** Copying certificates"
docker cp ssl/certificate.pem wodin-proxy:/run/proxy/
docker cp ssl/key.pem wodin-proxy:/run/proxy/
fi
echo "*** Done, wodin should now be available at $PROTOCOL://$WODIN_HOST"