forked from michielbdejong/fxa-self-hosting
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
145 lines (123 loc) · 3.82 KB
/
setup.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
#!/bin/bash
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 1 ] || die "1 argument required, $# provided"
echo $1 | grep -E -q '^[-a-z0-9\.]+$' || die "Argument $1 does not look like a domain name"
[ -f "/fxa-cert/combined.pem" ] || die "/fxa-cert/combined.pem does not exist"
[ -f "/fxa-cert/privkey.pem" ] || die "/fxa-cert/privkey.pem does not exist"
echo Creating syncserver-config
mkdir -p syncserver-config
# Adapted from https://github.com/mozilla-services/syncserver/blob/master/syncserver.ini
cat <<EOF > syncserver-config/syncserver.ini
[server:main]
use = egg:gunicorn
host = 0.0.0.0
port = 5000
workers = 1
timeout = 30
[app:main]
use = egg:syncserver
[syncserver]
force_wsgi_environ = true
public_url = https://$1:5000/
audiences = https://$1:5000
EOF
echo Creating auth-config
mkdir -p auth-config
docker run -v `pwd`/auth-config:/config:rw \
fxa-auth-server \
bash -c "cd ./scripts/ && node ./gen_keys.js && cp ../config/*-key.json /config"
echo Stopping all running Docker containers
docker stop `docker ps -q`
docker rm `docker ps -aq`
echo Starting up services for $1
cd ~/notes
docker run -d \
-e "HOST=0.0.0.0" \
--name httpdb \
fxa-auth-db-mysql
docker run -d \
--name verifier.local \
-e "IP_ADDRESS=0.0.0.0" \
-e "PORT=5050" \
browserid-verifier
docker run -d \
--name profile \
-e "PUBLIC_URL=https://$1:1111" \
-e "AUTH_SERVER_URL=https://$1/v1" \
-e "OAUTH_SERVER_URL=https://$1:9010/v1" \
-e "IMG=local" \
-e "HOST=0.0.0.0" \
fxa-profile-server
docker run -d \
--name syncto \
-e "SYNCTO_TOKEN_SERVER_URL=https://$1:5000/token/" \
syncto
docker run -d \
--name content \
-e "PUBLIC_URL=https://$1:3030" \
-e "FXA_URL=https://$1" \
-e "FXA_OAUTH_URL=https://$1:9010" \
-e "FXA_PROFILE_URL=https://$1:1111" \
-e "REDIRECT_PORT=3031" \
fxa-content-server
echo Sleeping to let services come up before linking
sleep 5
docker run -d \
--name sync \
--link="verifier.local" \
-v `pwd`/syncserver-config:/config:ro \
--entrypoint ./local/bin/gunicorn \
syncserver \
--paste /config/syncserver.ini
docker run -d \
--name auth \
--link="httpdb" \
-v `pwd`/auth-config:/config:ro \
-e "IP_ADDRESS=0.0.0.0" \
-e "PUBLIC_URL=https://$1" \
-e "HTTPDB_URL=http://httpdb:8000" \
-e "OAUTH_URL=https://$1:9010" \
fxa-auth-server \
bash -c "cp /config/*-key.json ./config && node ./bin/key_server.js | node ./bin/notifier.js"
docker run -d \
--link="verifier.local" \
--name oauth \
-e "PUBLIC_URL=https://$1:9010" \
-e "HOST=0.0.0.0" \
-e "CONTENT_URL=https://$1:3030/oauth/" \
-e "VERIFICATION_URL=http://verifier.local:5050/v2" \
-e "ISSUER=$1" \
fxa-oauth-server
echo Sleeping to let services come up before linking
sleep 5
echo Setting up proxy
docker run -d \
--name proxy \
--link="profile" \
-p 1111:1111 \
--link="content" \
-p 3030:3030 \
--link="sync" \
-p 5000:5000 \
--link="syncto" \
-p 8000:8000 \
--link="auth" \
-p 443:9000 \
--link="oauth" \
-p 9010:9010 \
-v `pwd`/fxa-cert:/fxa-cert \
fxa-self-hosting
docker ps -a
echo You should see 9 servers
echo - fxa-self-hosting,
echo - fxa-oauth-server,
echo - fxa-auth-server,
echo - fxa-content-server,
echo - syncto,
echo - syncserver,
echo - fxa-profile-server,
echo - browserid-verifier,
echo - fxa-auth-db-mysql