Browse Source

Added new version

Updated init-letsencrypt

updated init-letsencrypt with docker-compose-init

updated init-letsencrypt with docker-compose-init

restored init-letsencrypt

updates to certbot

updates to certbot

updates to certbot

updates to certbot

updates to certbot

updates to certbot

updates to certbot

added certbot to scalelite-nginx

fixed settings for acme-challenge

added blacklist

updated init-letsencrypt for working with scaleite-nginx

Removed unnecessary files

percisted certbot logs and added env options to init-letsencrypt
master
jfederico 4 years ago
parent
commit
a6e93f19e3

+ 7
- 2
.gitignore View File

@@ -1,7 +1,5 @@
1 1
 .env
2 2
 
3
-/data*
4
-
5 3
 /nginx/log*
6 4
 /nginx/sites-available*
7 5
 /nginx/sites-enabled*
@@ -11,3 +9,10 @@
11 9
 
12 10
 /scalelite/log*
13 11
 /scalelite/tmp*
12
+
13
+/data/*
14
+!/data/nginx/
15
+
16
+/tmp*
17
+
18
+/log*

+ 0
- 383
README.md View File

@@ -1,383 +0,0 @@
1
-# scalelite-run
2
-
3
-This document provides instructions on how to quickly [Scalelite](https://github.com/blindsidenetworks/scalelite), a stateful BigBlueButton load balancer, using docker-compose.
4
-
5
-This can be performed as an [All-In-One-Box Deployment](#all-in-one-box-deployment) or making use of distributed services in the cloud (or virtual private cloud) through a cloud computing provider as a [Distributed Deployment](#distributed-deployment).
6
-
7
-<a name="prerequisites"/>
8
-
9
-## Prerequisites
10
-
11
-Scalelite requires a server with 4 CPU cores and 8 Gig of memory.  Since all the component run under docker, the underlying OS need only support docker and docker-compose.
12
-
13
-These steps were written for an Ubuntu 18.04 machine. It is assumed that your machine has the same (or a compatible version).  
14
-
15
-You need to have a fully qualified domain name (FQDN) for the Scalelite server, such as bbb-lb.example.com, that resolves to the public IP address of the server.  
16
-
17
-To setup the server, first install both [docker](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04) and [docker-compose](https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-18-04).
18
-
19
-Next, clone the `scalelite-run` repository
20
-
21
-```
22
-git clone git@github.com:blindsidenetworks/scalelite-run.git
23
-cd scalelite-run
24
-```
25
-
26
-<a name="all-in-one-box-deployment"/>
27
-
28
-## I. All-In-One-Box Deployment
29
-
30
-<a name="initial-settings"/>
31
-
32
-### 1. Initial settings
33
-
34
-Copy `dotenv` file located in the root of the project as `.env` and edit it.
35
-
36
-```
37
-cp dotenv .env
38
-```
39
-
40
-You need to replace the variable `HOST_NAME=sl.xlab.blindside-dev.com` with a hostname under your own domain name (e.g. `HOST_NAME=sl.john.blindside-dev.com`) or delegated sub-domain.
41
-
42
-```
43
-vi .env
44
-```
45
-
46
-Copy `dotenv` file located in the scalelite directory as `.env` and in the same way as before, edit it:
47
-
48
-```
49
-cp scalelite/dotenv scalelite/.env
50
-```
51
-
52
-You can start it as is, but you may want to replace both variables with your own values.
53
-
54
-- `SECRET_KEY_BASE` is the Ruby On Rails secret key and must be replaced with a random one generated with `openssl rand -hex 64`.
55
-- `LOADBALANCER_SECRET` is the shared secret used by external applications for accessing Scalelite LoadBalancer as if it was a BigBlueButton server. This variable must be defined in order for the application to start. A secret can be generated with `openssl rand -hex 24`
56
-
57
-```
58
-vi scalelite/.env
59
-```
60
-
61
-<a name="ssl-certificate"/>
62
-
63
-### 2. SSL Certificate
64
-
65
-The docker-compose scripts come configured for using SSL Certificates, but you may want not to use an SSL certificate. If this is the case see the section [Removing SSL Certificate](#removing-ssl-certificate) in [Special Cases](#special-cases).
66
-
67
-The procedure for setting up the SSL Certificate will be different depending if [Let's Encrypt SSL CA](#letsencrypt-ssl-ca) CA or [Other SSL CA](#other-ssl-ca) will be used.
68
-
69
-<a name="letsencrypt-ssl-ca"/>
70
-
71
-#### 2.1. Using Let's Encrypt SSL CA
72
-
73
-There are also two paths that can be followed whether the box where Scalelite is going to be installed is [visible from the Internet](#letsencrypt-ssl-public-network) or [NOT visible from the Internet](#letsencrypt-ssl-private-network).
74
-
75
-<a name="letsencrypt-ssl-public-network"/>
76
-
77
-##### 2.1.1. Server is visible from the Internet
78
-
79
-If all the previous steps were properly followed and the machine is accessible in the Internet, only execute:
80
-
81
-```
82
-./init-letsencrypt.sh
83
-```
84
-
85
-This will generate the SSL certificates and run scalelite for the first time, so all the required files are automatically generated.
86
-
87
-<a name="letsencrypt-ssl-private-network"/>
88
-
89
-##### 2.1.2. Server is NOT visible from the Internet
90
-
91
-If you are trying to install scalelite locally or in a private network, the SSL certificate must be generated manually using certbot and by adding the manual challenge to the DNS.
92
-
93
-Install Let's Encrypt
94
-
95
-```
96
-sudo apt-get update
97
-sudo apt-get -y install letsencrypt
98
-```
99
-
100
-Become root
101
-
102
-```
103
-sudo -i
104
-```
105
-
106
-Start creating the certificates
107
-
108
-```
109
-certbot certonly --manual -d sl.<JOHN>.blindside-dev.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges=dns --email hostmaster@blindsdie-dev.com --server https://acme-v02.api.letsencrypt.org/directory
110
-```
111
-
112
-The output should look like this example
113
-
114
-```
115
--server https://acme-v02.api.letsencrypt.org/directory
116
-Saving debug log to /var/log/letsencrypt/letsencrypt.log
117
-Plugins selected: Authenticator manual, Installer None
118
-Obtaining a new certificate
119
-Performing the following challenges:
120
-dns-01 challenge for gl.<JOHN>.blindside-dev.com
121
-dns-01 challenge for gl.<JOHN>.blindside-dev.com
122
-
123
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
124
-Please deploy a DNS TXT record under the name
125
-_acme-challenge.sl.<JOHN>.blindside-dev.com with the following value:
126
-
127
-2dxWYkcETHnimmQmCL0MCbhneRNxMEMo9yjk6P_17kE
128
-
129
-Before continuing, verify the record is deployed.
130
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131
-Press Enter to Continue
132
-```
133
-
134
-Create a TXT record in the DNS for
135
-`_acme-challenge.sl.<JOHN>.blindside-dev.com` with the challenge string as
136
-its value `2dxWYkcETHnimmQmCL0MCbhneRNxMEMo9yjk6P_17kE`
137
-
138
-Copy the certificates to the scalelite-run directory. Although `/etc/letsencrypt/live/`
139
-holds the latest certificate, they are only symbolic links. The real files must be copied and renamed
140
-
141
-```
142
-cp -R /etc/letsencrypt <YOUR ROOT>/scalelite-run/data/certbot/conf
143
-```
144
-
145
-<a name="other-ssl-ca"/>
146
-
147
-#### 2.2. Using Other SSL CA
148
-
149
-For adding an SSL certificate from an CA other than Let's Encrypt,
150
-
151
-DO NOT execute the `./init-letsencrypt.sh` script
152
-
153
-Place the SSL Certificate, Intermediate Certificate (or Bundle with both of them if you have it) and Private Key files inside `nginx/ssl` as `fullchain.pem` and `privkey.pem`.
154
-E.g.
155
-```
156
-cd ~/
157
-cat your_domain_name.crt Intermediate.crt >> bundle.crt
158
-cp bundle.crt <YOUR ROOT>/scalelite/nginx/ssl/fullchain.pem
159
-cp private.key <YOUR ROOT>/scalelite/nginx/ssl/privkey.pem
160
-```
161
-
162
-Edit the template for nginx.
163
-```
164
-cd <YOUR ROOT>/scalelite
165
-vi nginx/sites.template
166
-```
167
-Comment the lines referencing the Let's Encrypt Certificate and uncomment the other two. After that, it should look like this:
168
-
169
-```
170
-...
171
-    ## Configuration for Letsencrypt SSL Certificate
172
-    #ssl_certificate /etc/letsencrypt/live/$NGINX_HOSTNAME/fullchain.pem;
173
-    #ssl_certificate_key /etc/letsencrypt/live/$NGINX_HOSTNAME/privkey.pem;
174
-
175
-    ## Configuration for SSL Certificate from a CA other than Letsencrypt
176
-    ssl_certificate /etc/ssl/fullchain.pem;
177
-    ssl_certificate_key /etc/ssl/privkey.pem;
178
-...
179
-```
180
-
181
-Comment out in `docker-compose.yml` the certbot container. After that, it should look like this:
182
-
183
-```
184
-...
185
-## Configuration for Letsencrypt SSL Certificate
186
-## comment out when using an SSL Certificate from a CA other than Letsencrypt
187
-#  certbot:
188
-#    image: certbot/certbot
189
-#    volumes:
190
-#      - ./data/certbot/conf:/etc/letsencrypt
191
-#      - ./data/certbot/www:/var/www/certbot
192
-#    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
193
-...
194
-```
195
-
196
-Start the containers as usual.
197
-
198
-<a name="start-up"/>
199
-
200
-### 3. Start Up
201
-
202
-And finally, start the application with docker-compose
203
-
204
-```
205
-cd <YOUR ROOT>/scalelite-run
206
-docker-compose up
207
-```
208
-
209
-If everything goes well, the logs will show ip in the console for all the containers starting and scalelite will be available at:
210
-
211
-```
212
-https://sl.<JOHN>.blindside-dev.com/bigbluebutton/api
213
-```
214
-
215
-Note that the application can be run in the background with `docker-compose up -d`
216
-
217
-<a name="final-steps"/>
218
-
219
-### 4. Final Steps
220
-
221
-<a name="initializing-pool"/>
222
-
223
-#### 4.1. Initializing pool of servers
224
-Since there are no servers added by default, atleast 1 server must be added and enabled in order to get started.
225
-
226
-Open a new console and get the IDs of the docker containers running:
227
-
228
-```
229
-docker ps
230
-```
231
-
232
-Get into the container running the api
233
-
234
-```
235
-docker exec -it <CONTAINER_ID> sh
236
-```
237
-
238
-Once inside, all the rails commands can be executed as needed. In this case, and assuming that the current current BigBlueButton server is going to be enabled.
239
-
240
-```
241
-bundle exec rake servers:add[BIGBLUEBUTTON_SERVER_URL,BIGBLUEBUTTON_SERVER_SECRET]
242
-bundle exec rake servers
243
-bundle exec rake servers:enable["SERVER_ID_AS SHOWN"]
244
-```
245
-
246
-For more information on what rake commands can be executed, see [scalelite documentation](https://github.com/blindsidenetworks/scalelite#administration).
247
-
248
-<a name="rolling-out-updates"/>
249
-
250
-#### 4.2. Rolling-out updates
251
-
252
-Scalelite is constantly updated. Either because of bug fixes or improvements. It is recommended to keep the deployment updated with the latest image available, which corresponds to the latest stable release.
253
-
254
-Those updates can be performed manually (recommended for a production alike environment) or automatically.
255
-
256
-<a name="rolling-out-updates-manual"/>
257
-
258
-##### 4.2.1. Manual updates
259
-
260
-Simply run the `deploy.sh` script included under `scripts`.
261
-
262
-```
263
-cd <YOUR ROOT>/scalelite-run
264
-sudo .scripts/deploy.sh
265
-```
266
-
267
-<a name="rolling-out-updates-automatic"/>
268
-
269
-##### 4.2.2. Automatic updates
270
-
271
-Use the scripts provided.
272
-
273
-```
274
-sudo ln -s <YOUR ROOT>/scalelite-run/scripts/deploy.sh /usr/local/bin/scalelite-deploy
275
-sudo cp <YOUR ROOT>/scalelite-run/scripts/scalelite-auto-deployer.service /etc/systemd/system/scalelite-auto-deployer.service
276
-sudo cp <YOUR ROOT>/scalelite-run/scripts/scalelite-auto-deployer.timer /etc/systemd/system/scalelite-auto-deployer.timer
277
-sudo systemctl daemon-reload
278
-sudo systemctl enable scalelite-auto-deployer.service
279
-sudo systemctl enable scalelite-auto-deployer.timer
280
-sudo systemctl start scalelite-auto-deployer.timer
281
-```
282
-
283
-<a name="starting-automatic"/>
284
-
285
-##### 4.2.3. Automatic start
286
-
287
-Use the scripts provided.
288
-
289
-```
290
-```
291
-
292
-<a name="distributed-deployment"/>
293
-
294
-## II. Distributed Deployment
295
-
296
-On a real production environment Scalelite should be deployed using distributed services in the cloud (or virtual private cloud) through a cloud computing provider like [AWS](https://aws.amazon.com/), [Google Cloud](https://cloud.google.com/), [Azure](https://azure.microsoft.com/en-ca/), [Digital Ocean](https://www.digitalocean.com/), [Alibaba Cloud](https://www.alibabacloud.com/), etc.
297
-
298
-Contact us at [Blindside Networks Contact](https://blindsidenetworks.com/contact/) getting recommendations on best practices with any of those cloud providers.
299
-
300
-<a name="special-cases"/>
301
-
302
-## III. Special cases
303
-
304
-<a name="building-docker-image"/>
305
-
306
-### Building Docker image
307
-
308
-If no access to the DockerHub registry is available, it is still possible to build the image. Either by running `docker build` where scalelite code is placed, or using the build script provided in this repo at `scripts/build.sh`. The only advantage of using the script is that the last commit is included as the build number.
309
-
310
-```
311
-cd <YOUR ROOT>/scalelite
312
-docker build -t blindsidenetwks/scalelite:latest .
313
-```
314
-
315
-or
316
-
317
-```
318
-cd <YOUR ROOT>/scalelite
319
-../scalelite-run/scripts/build.sh blindsidenetwks/scalelite latest
320
-```
321
-
322
-Keep in mind that the docker-compose.yml script makes use of some other configuration files that are mounted inside the containers. If any modification to nginx is needed it has to be done on the sites.template file. Also, whatever name is chosen for the image should match the one used in docker-compose.yml.
323
-
324
-<a name="removing-ssl-certificate"/>
325
-
326
-### Removing SSL Certificate
327
-
328
-DO NOT execute the `./init-letsencrypt.sh` script
329
-
330
-Edit the template for nginx.
331
-```
332
-cd <YOUR ROOT>/scalelite
333
-vi nginx/sites.template
334
-```
335
-Comment out all the lines from 13 to 34. The sites.template file should look like this:
336
-
337
-```
338
-...
339
-listen [::]:80;
340
-
341
-#    location /.well-known/acme-challenge/ {
342
-#        root /var/www/certbot;
343
-#    }
344
-#
345
-#    location / {
346
-#        return 301 https://$host$request_uri;
347
-#    }
348
-#}
349
-#
350
-#server {
351
-#    server_name $NGINX_HOSTNAME;
352
-#
353
-#    listen 443 ssl;
354
-#    listen [::]:443;
355
-#
356
-#    ## Configuration for Letsencrypt SSL Certificate
357
-#    ssl_certificate /etc/letsencrypt/live/$NGINX_HOSTNAME/fullchain.pem;
358
-#    ssl_certificate_key /etc/letsencrypt/live/$NGINX_HOSTNAME/privkey.pem;
359
-#
360
-#    ## Configuration for SSL Certificate from a CA other than Letsencrypt
361
-#    #ssl_certificate /etc/ssl/fullchain.pem;
362
-#    #ssl_certificate_key /etc/ssl/privkey.pem;
363
-
364
-     location / {
365
-...
366
-```
367
-
368
-Comment out in `docker-compose.yml` the certbot container. After that, it should look like this:
369
-
370
-```
371
-...
372
-## Configuration for Letsencrypt SSL Certificate
373
-## comment out when using an SSL Certificate from a CA other than Letsencrypt
374
-#  certbot:
375
-#    image: certbot/certbot
376
-#    volumes:
377
-#      - ./data/certbot/conf:/etc/letsencrypt
378
-#      - ./data/certbot/www:/var/www/certbot
379
-#    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
380
-...
381
-```
382
-
383
-Start the containers as usual.

+ 3
- 0
data/nginx/scalelite/acme-challenge.location View File

@@ -0,0 +1,3 @@
1
+location /.well-known/acme-challenge/ {
2
+    root /var/www/certbot;
3
+}

+ 9
- 0
data/nginx/scalelite/blacklist View File

@@ -0,0 +1,9 @@
1
+## Deny access to IPs or subnets.
2
+# deny IP;
3
+# deny subnet;
4
+# e.g.
5
+# deny 192.168.0.1;
6
+# deny 192.168.0.0/24;
7
+
8
+## Allow access to everything else.
9
+allow    all;

+ 71
- 70
docker-compose.yml View File

@@ -1,99 +1,100 @@
1 1
 version: '3'
2 2
 
3 3
 volumes:
4
-  database_data:
5
-    driver: local
4
+  postgres-data:
5
+  redis-data:
6 6
 
7 7
 services:
8
-  nginx:
9
-    image: nginx:latest
10
-    restart: "no"
11
-    volumes:
12
-      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
13
-      - ./nginx/sites-enabled:/etc/nginx/sites-enabled
14
-      - ./nginx/sites.template:/etc/nginx/sites-available/sites.template
15
-      - ./nginx/default/html:/var/www/html
16
-      - ./nginx/log/nginx:/var/log/nginx
17
-      - ./data/certbot/conf:/etc/letsencrypt
18
-      - ./data/certbot/www:/var/www/certbot
19
-      - ./nginx/ssl/:/etc/ssl
8
+  postgres:
9
+    image: postgres:11.5-alpine
10
+    container_name: postgres
11
+    restart: unless-stopped
20 12
     ports:
21
-      - "80:80"
22
-      - "443:443"
13
+      - "127.0.0:5432:5432"
14
+    volumes:
15
+      - postgres-data:/var/lib/postgresql/data
23 16
     environment:
24
-      - NGINX_HOSTNAME=${HOST_NAME:-sl.xlab.blindside-dev.com}
25
-    depends_on:
26
-      - scalelite.api
27
-    command: /bin/bash -c "envsubst '$$NGINX_HOSTNAME' < /etc/nginx/sites-available/sites.template > /etc/nginx/sites-enabled/sites.conf && while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g 'daemon off;'"
17
+      - POSTGRES_USER=${POSTGRES_USER:-postgres}
18
+      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
28 19
 
20
+  redis:
21
+    image: redis:5.0-alpine
22
+    container_name: redis
23
+    restart: on-failure
24
+    ports:
25
+      - 127.0.0.1:6379:6379
26
+    volumes:
27
+      - redis-data:/data
29 28
 
30
-## Configuration for Letsencrypt SSL Certificate
31
-## comment out when using an SSL Certificate from a CA other than Letsencrypt
32 29
   certbot:
33 30
     image: certbot/certbot
31
+    container_name: certbot
34 32
     volumes:
33
+      - ./log/certbot:/var/log/letsencrypt
35 34
       - ./data/certbot/conf:/etc/letsencrypt
36 35
       - ./data/certbot/www:/var/www/certbot
37 36
     entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
38 37
 
39
-
40
-  redis:
41
-    image: redis:5.0-alpine
42
-    restart: "no"
38
+  scalelite-nginx:
39
+    image: ${SCALELITE_REPO:-blindsidenetwks}/scalelite:${SCALELITE_TAG:-v1}-nginx
40
+    container_name: scalelite-nginx
41
+    restart: unless-stopped
43 42
     ports:
44
-      - 127.0.0.1:6379:6379
45
-    volumes:
46
-      - ./data/redis/:/data
47
-
48
-
49
-  postgres:
50
-    image: postgres:11.7-alpine
51
-    restart: "no"
52
-    ports:
53
-      - 127.0.0.1:5432:5432
43
+      - "80:80"
44
+      - "443:443"
54 45
     volumes:
55
-      - ./data/postgres/:/var/lib/postgresql/data
46
+      - ./log/nginx/:/var/log/nginx
47
+      - ./data/certbot/conf:/etc/nginx/ssl
48
+      - ./data/certbot/www:/var/www/certbot
49
+      - ./data/nginx/scalelite:/etc/nginx/conf.d/scalelite
50
+      - ${SCALELITE_RECORDING_DIR-/mnt/scalelite-recordings/var/bigbluebutton}/published:/var/bigbluebutton/published
56 51
     environment:
57
-      - POSTGRES_DB=postgres
58
-      - POSTGRES_USER=postgres
59
-      - POSTGRES_PASSWORD=password
60
-
52
+      - NGINX_SSL=${NGINX_SSL-true}
53
+      - URL_HOST=${URL_HOST}
54
+    depends_on:
55
+      - scalelite-api
61 56
 
62
-  scalelite.api:
63
-    entrypoint: [bin/start]
64
-    image: blindsidenetwks/scalelite:latest
65
-    restart: "no"
57
+  scalelite-api:
58
+    image: ${SCALELITE_REPO:-blindsidenetwks}/scalelite:${SCALELITE_TAG:-v1}-api
59
+    container_name: scalelite-api
60
+    restart: unless-stopped
66 61
     ports:
67
-      - 127.0.0.1:3000:3000
68
-    links:
69
-      - redis
70
-      - postgres
62
+      - "3000:3000"
71 63
     volumes:
72
-      - ./scalelite/log/api:/srv/scalelite/log
73
-      - ./scalelite/bin/start:/srv/scalelite/bin/start
74
-      - ./scalelite/config/database.yml:/srv/scalelite/config/database.yml
75
-      - ./scalelite/tmp/pids/:/usr/src/app/tmp/pids
76
-      - ./scalelite/tmp/sockets/:/usr/src/app/tmp/sockets
77
-      - ./scalelite/tmp/cache/assets:/usr/src/app/tmp/cache/assets
78
-    env_file: ./scalelite/.env
64
+      - ./log/scalelite/:/app/log
65
+      - ${SCALELITE_RECORDING_DIR-/mnt/scalelite-recordings/var/bigbluebutton}:/var/bigbluebutton
79 66
     environment:
67
+      - SECRET_KEY_BASE=${SECRET_KEY_BASE}
68
+      - LOADBALANCER_SECRET=${LOADBALANCER_SECRET}
80 69
       - REDIS_URL=${REDIS_URL:-redis://redis:6379}
81 70
       - DATABASE_URL=${DATABASE_URL:-postgres://postgres:password@postgres:5432/scalelite?pool=5}
82
-      - URL_HOST=${HOST_NAME:-sl.xlab.blindside-dev.com}
83
-
71
+      - URL_HOST=${URL_HOST}
72
+    depends_on:
73
+      - postgres
74
+      - redis
84 75
 
85
-  scalelite.poller:
86
-    entrypoint: [bin/start-poller]
87
-    image: blindsidenetwks/scalelite:latest
88
-    restart: "no"
89
-    ports:
90
-      - 127.0.0.1:3001:3000
91
-    links:
76
+  scalelite-poller:
77
+    image: ${SCALELITE_REPO:-blindsidenetwks}/scalelite:${SCALELITE_TAG:-v1}-poller
78
+    container_name: scalelite-poller
79
+    restart: unless-stopped
80
+    environment:
81
+      - REDIS_URL=${REDIS_URL:-redis://redis:6379}
82
+      - DATABASE_URL=${DATABASE_URL:-postgres://postgres:password@postgres:5432/scalelite?pool=5}
83
+    depends_on:
84
+      - postgres
92 85
       - redis
93
-    volumes:
94
-      - ./scalelite/log/poller:/srv/scalelite/log
95
-      - ./scalelite/bin/start-poller:/srv/scalelite/bin/start-poller
96
-    env_file: ./scalelite/.env
86
+      - scalelite-api
87
+
88
+  scalelite-recording-importer:
89
+    image: ${SCALELITE_REPO:-blindsidenetwks}/scalelite:${SCALELITE_TAG:-v1}-recording-importer
90
+    container_name: scalelite-recording-importer
91
+    restart: unless-stopped
97 92
     environment:
98 93
       - REDIS_URL=${REDIS_URL:-redis://redis:6379}
99
-      - URL_HOST=${HOST_NAME:-sl.xlab.blindside-dev.com}
94
+      - DATABASE_URL=${DATABASE_URL:-postgres://postgres:password@postgres:5432/scalelite?pool=5}
95
+    volumes:
96
+      - ${SCALELITE_RECORDING_DIR-/mnt/scalelite-recordings/var/bigbluebutton}:/var/bigbluebutton
97
+    depends_on:
98
+      - postgres
99
+      - redis
100
+      - scalelite-api

+ 23
- 3
dotenv View File

@@ -1,3 +1,23 @@
1
-HOST_NAME=sl.xlab.blindside-dev.com
2
-REDIS_URL=redis://redis:6379
3
-DATABASE_URL=postgres://postgres:password@postgres:5432/scalelite?pool=5
1
+### Required by scalelite-api
2
+# SECRET_KEY_BASE=
3
+# LOADBALANCER_SECRET=
4
+#
5
+### Required by scalelite-api and scalelite-poller
6
+# REDIS_URL=
7
+#
8
+### Required by scalelite-api and scalelite-recording-importer
9
+# DATABASE_URL=
10
+# SCALELITE_RECORDING_DIR=/mnt/scalelite-recordings/var/bigbluebutton
11
+#
12
+### Required by scalelite-nginx (only When using SSL)
13
+# NGINX_SSL=true
14
+# SCALELITE_NGINX_EXTRA_OPTS=--mount type=bind,source=/etc/letsencrypt,target=/etc/nginx/ssl,readonly
15
+# URL_HOST=
16
+#
17
+### Required when when specific repo or version (other than defaults) are needed
18
+# SCALELITE_REPO=blindsidenetwks
19
+# SCALELITE_TAG=v1
20
+#
21
+### Optional for postgres when using docker-compose
22
+# POSTGRES_USER=
23
+# POSTGRES_PASSWORD=

+ 9
- 8
init-letsencrypt.sh View File

@@ -5,13 +5,14 @@ if ! [ -x "$(command -v docker-compose)" ]; then
5 5
   exit 1
6 6
 fi
7 7
 
8
-HOST_NAME=$(grep HOST_NAME .env | cut -d '=' -f2)
8
+URL_HOST=$(grep URL_HOST .env | cut -d '=' -f2)
9
+echo $URL_HOST
9 10
 
10
-domains=($HOST_NAME)
11
+domains=($URL_HOST)
11 12
 rsa_key_size=4096
12 13
 data_path="./data/certbot"
13
-email="" # Adding a valid address is strongly recommended
14
-staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits
14
+email="$LETSENCRYPT_EMAIL" # Adding a valid address is strongly recommended
15
+staging=${LETSENCRYPT_STAGING:-0} # Set to 1 if you're testing your setup to avoid hitting request limits
15 16
 
16 17
 if [ -d "$data_path" ]; then
17 18
   read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision
@@ -40,8 +41,8 @@ docker-compose run --rm --entrypoint "\
40 41
 echo
41 42
 
42 43
 
43
-echo "### Starting nginx ..."
44
-docker-compose up --force-recreate -d nginx
44
+echo "### Starting scalelite-nginx ..."
45
+docker-compose up --force-recreate -d scalelite-nginx
45 46
 echo
46 47
 
47 48
 echo "### Deleting dummy certificate for $domains ..."
@@ -78,5 +79,5 @@ docker-compose run --rm --entrypoint "\
78 79
     --force-renewal" certbot
79 80
 echo
80 81
 
81
-echo "### Reloading nginx ..."
82
-docker-compose exec nginx nginx -s reload
82
+echo "### Reloading scalelite-nginx ..."
83
+docker-compose exec scalelite-nginx nginx -s reload

+ 0
- 25
nginx/default/html/index.html View File

@@ -1,25 +0,0 @@
1
-<!DOCTYPE html>
2
-<html>
3
-<head>
4
-<title>Welcome to nginx!</title>
5
-<style>
6
-    body {
7
-        width: 35em;
8
-        margin: 0 auto;
9
-        font-family: Tahoma, Verdana, Arial, sans-serif;
10
-    }
11
-</style>
12
-</head>
13
-<body>
14
-<h1>Welcome to nginx!</h1>
15
-<p>If you see this page, the nginx web server is successfully installed and
16
-working. Further configuration is required.</p>
17
-
18
-<p>For online documentation and support please refer to
19
-<a href="http://nginx.org/">nginx.org</a>.<br/>
20
-Commercial support is available at
21
-<a href="http://nginx.com/">nginx.com</a>.</p>
22
-
23
-<p><em>Thank you for using nginx.</em></p>
24
-</body>
25
-</html>

+ 0
- 37
nginx/nginx.conf View File

@@ -1,37 +0,0 @@
1
-user  nginx;
2
-worker_processes  1;
3
-
4
-error_log  /var/log/nginx/error.log warn;
5
-pid        /var/run/nginx.pid;
6
-
7
-
8
-events {
9
-    worker_connections  1024;
10
-}
11
-
12
-
13
-http {
14
-    include       /etc/nginx/mime.types;
15
-    default_type  application/octet-stream;
16
-
17
-    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
18
-                      '$status $body_bytes_sent "$http_referer" '
19
-                      '"$http_user_agent" "$http_x_forwarded_for"';
20
-
21
-    access_log  /var/log/nginx/access.log  main;
22
-
23
-    sendfile        on;
24
-    #tcp_nopush     on;
25
-
26
-    keepalive_timeout  65;
27
-
28
-    #gzip  on;
29
-
30
-    include /etc/nginx/conf.d/*.conf;
31
-
32
-    ##
33
-    # Virtual Host Configs
34
-    ##
35
-
36
-    include /etc/nginx/sites-enabled/*;
37
-}

+ 0
- 55
nginx/sites.template View File

@@ -1,55 +0,0 @@
1
-#### For <$NGINX_HOSTNAME>
2
-
3
-upstream docker-scalelite {
4
-    server scalelite.api:3000;
5
-}
6
-
7
-server {
8
-    server_name $NGINX_HOSTNAME;
9
-
10
-    listen 80;
11
-    listen [::]:80;
12
-
13
-    location /.well-known/acme-challenge/ {
14
-        root /var/www/certbot;
15
-    }
16
-
17
-    location / {
18
-        return 301 https://$host$request_uri;
19
-    }
20
-}
21
-
22
-server {
23
-    server_name $NGINX_HOSTNAME;
24
-
25
-    listen 443 ssl;
26
-    listen [::]:443;
27
-
28
-    ## Configuration for Letsencrypt SSL Certificate
29
-    ssl_certificate /etc/letsencrypt/live/$NGINX_HOSTNAME/fullchain.pem;
30
-    ssl_certificate_key /etc/letsencrypt/live/$NGINX_HOSTNAME/privkey.pem;
31
-
32
-    ## Configuration for SSL Certificate from a CA other than Letsencrypt
33
-    #ssl_certificate /etc/ssl/fullchain.pem;
34
-    #ssl_certificate_key /etc/ssl/privkey.pem;
35
-
36
-    location / {
37
-            proxy_pass  http://docker-scalelite;
38
-            proxy_read_timeout 60s;
39
-            proxy_redirect off;
40
-
41
-            proxy_set_header  Host $http_host;
42
-
43
-            proxy_set_header  X-Real-IP $remote_addr;
44
-            proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
45
-            proxy_set_header  Cookie "$http_cookie; ip=$remote_addr";
46
-
47
-            proxy_set_header  X-Forwarded-Proto $scheme;
48
-
49
-            proxy_http_version 1.1;
50
-            proxy_set_header Upgrade $http_upgrade;
51
-            proxy_set_header Connection "upgrade";
52
-
53
-            rewrite ~/(.*)$ /$1 break;
54
-    }
55
-}

+ 0
- 0
nginx/ssl/.placeholder_for_ssl_certificates View File


+ 0
- 0
redis/.keep View File


+ 0
- 34
scalelite/bin/start View File

@@ -1,34 +0,0 @@
1
-#!/bin/sh
2
-
3
-if [ "$LOADBALNCER_SECRET" == "loadbalancer_secret" ] || [ "$SECRET_KEY_BASE" == "secret_key_base" ]; then
4
-  echo "ERROR: Detected default SECRET_KEY_BASE or LOADBALANCER_SECRET. Please generate a random value."
5
-  echo "Exiting..."
6
-  exit 1
7
-fi
8
-
9
-servers="$(RAILS_ENV=$RAILS_ENV bundle exec rake servers 2>&1)"
10
-echo $servers
11
-
12
-if [ "$RAILS_ENV" = "production" ] && [ "$DB_ADAPTER" = "postgresql" ]; then
13
-  while ! curl http://$DB_HOST:${DB_PORT:-5432}/ 2>&1 | grep '52'
14
-  do
15
-    echo "Waiting for postgres to start up ..."
16
-    sleep 1
17
-  done
18
-fi
19
-
20
-db_create="$(RAILS_ENV=$RAILS_ENV bundle exec rake db:create 2>&1)"
21
-echo $db_create
22
-
23
-if [[ $db_create == *"already exists"* ]]; then
24
-  echo ">>> Database migration"
25
-  bundle exec rake db:migrate
26
-else
27
-  echo ">>> Database initialization"
28
-  bundle exec rake db:schema:load
29
-fi
30
-
31
-exec tini -- bundle exec puma -C config/puma.rb "$@"
32
-#tail -f /dev/null
33
-#bundle exec puma -C config/puma.rb
34
-#bundle exec rails s -b 0.0.0.0 -p 3000

+ 0
- 5
scalelite/bin/start-poller View File

@@ -1,5 +0,0 @@
1
-#!/bin/sh
2
-
3
-echo "Poller is starting..."
4
-exec tini -- bundle exec rake poll["$INTERVAL"]
5
-#tail -f /dev/null

+ 0
- 23
scalelite/config/database.yml View File

@@ -1,23 +0,0 @@
1
-default: &default
2
-  pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
3
-  timeout: 5000
4
-  adapter: postgresql
5
-  host: <%= ENV['DB_HOST'] %>
6
-  username: <%= ENV['DB_USERNAME'] %>
7
-  password: <%= ENV['DB_PASSWORD'] %>
8
-  encoding: unicode
9
-
10
-development:
11
-  <<: *default
12
-  database: scalelite_development
13
-
14
-# Warning: The database defined as "test" will be erased and
15
-# re-generated from your development database when you run "rake".
16
-# Do not set this db to the same as development or production.
17
-test:
18
-  <<: *default
19
-  database: scalelite_test
20
-
21
-production:
22
-  <<: *default
23
-  database: <%= ENV['DB_NAME'] || 'scalelite' %>

+ 0
- 2
scalelite/dotenv View File

@@ -1,2 +0,0 @@
1
-SECRET_KEY_BASE=secret_key_base
2
-LOADBALANCER_SECRET=loadbalancer_secret

+ 0
- 13
scripts/README.md View File

@@ -1,13 +0,0 @@
1
-# Helpers
2
-
3
-## Running automatic updates
4
-
5
-```
6
-sudo ln -s /home/ubuntu/scalelite-run/scripts/deploy.sh /usr/local/bin/scalelite-deploy
7
-sudo cp /home/ubuntu/scalelite-run/scripts/scalelite-auto-deployer.service /etc/systemd/system/scalelite-auto-deployer.service
8
-sudo cp /home/ubuntu/scalelite-run/scripts/scalelite-auto-deployer.timer /etc/systemd/system/scalelite-auto-deployer.timer
9
-sudo systemctl daemon-reload
10
-sudo systemctl enable scalelite-auto-deployer.service
11
-sudo systemctl enable scalelite-auto-deployer.timer
12
-sudo systemctl start scalelite-auto-deployer.timer
13
-```

+ 0
- 90
scripts/build.sh View File

@@ -1,90 +0,0 @@
1
-#!/bin/bash
2
-
3
-################################################################################
4
-# For this script to work properly it is required to define some environment variables
5
-# in the CI/CD Env variable declaration, while others should be passed as parameters.
6
-#
7
-#------------------------------------------------------------------------------
8
-# Defined as part of the CD/CI Env Variables:
9
-#
10
-# CD_DOCKER_USERNAME
11
-# A DockerHub username to be used for uploading the build.
12
-#
13
-# CD_DOCKER_PASSWORD
14
-# A DockerHub password to be used for uploading the build.
15
-#
16
-# CD_DOCKER_REPO
17
-# A DockerHub repository. By default the CD_REF_SLUG is also used as the docker repo.
18
-#
19
-# CD_BUILD_ALL
20
-# As the build is supposed to be done only for master (for a nightly deployments) and for releases
21
-# (like 'release-2.0.5' for production deployments), it is additionally required to include this
22
-# variable in order to build any other brnach, as it may be required for testing or reviewing work
23
-# as part of the development process.
24
-#
25
-
26
-display_usage() {
27
-  echo "This script should be used as part of a CI strategy."
28
-  echo -e "Usage:\n  build_image.sh [ARGUMENTS]"
29
-  echo -e "\nMandatory arguments \n"
30
-  echo -e "  repo_slug     The git repository  (e.g. blindsidenetworks/scalelite)"
31
-  echo -e "\nOptional arguments \n"
32
-  echo -e "  branch | tag  The branch (e.g. master | release-2.0.5)"
33
-}
34
-
35
-# if less than two arguments supplied, display usage
36
-if [ $# -le 0 ]; then
37
-	display_usage
38
-	exit 1
39
-fi
40
-
41
-# check whether user had supplied -h or --help . If yes display usage
42
-if [[ ($# == "--help") ||  $# == "-h" ]]; then
43
-	display_usage
44
-	exit 0
45
-fi
46
-
47
-export CD_REF_SLUG=$1
48
-export CD_REF_NAME=$2
49
-if [ -z $CD_REF_NAME ]; then
50
-  export CD_REF_NAME=$(git branch | grep \* | cut -d ' ' -f2)
51
-fi
52
-
53
-if [ "$CD_REF_NAME" != "master" ] && [[ "$CD_REF_NAME" != *"release"* ]] && ( [ -z "$CD_BUILD_ALL" ] || [ "$CD_BUILD_ALL" != "true" ] ); then
54
-  echo "#### Docker image for $CD_REF_SLUG:$CD_REF_NAME won't be built"
55
-  exit 0
56
-fi
57
-
58
-# Set the version tag when it is a release or the commit sha was included.
59
-if [[ "$CD_REF_NAME" == *"v"* ]]; then
60
-  export CD_BUILD_NUMBER=${CD_REF_NAME:1}
61
-else
62
-  export CD_BUILD_NUMBER="$CD_REF_NAME ($(eval git rev-parse --short=7 HEAD))"
63
-fi
64
-
65
-# Build the image
66
-if [ -z $CD_DOCKER_REPO ]; then
67
-  export CD_DOCKER_REPO=$CD_REF_SLUG
68
-fi
69
-echo "#### Docker image $CD_DOCKER_REPO:$CD_REF_NAME is being built"
70
-docker build --build-arg BUILD_NUMBER="${CD_BUILD_NUMBER}" -t $CD_DOCKER_REPO:$CD_REF_NAME .
71
-
72
-if [ -z "$CD_DOCKER_USERNAME" ] || [ -z "$CD_DOCKER_PASSWORD" ]; then
73
-  echo "#### Docker image for $CD_DOCKER_REPO can't be published because CD_DOCKER_USERNAME or CD_DOCKER_PASSWORD are missing (Ignore this warning if running outside a CD/CI environment)"
74
-  exit 0
75
-fi
76
-
77
-# Publish the image
78
-docker login -u="$CD_DOCKER_USERNAME" -p="$CD_DOCKER_PASSWORD"
79
-echo "#### Docker image $CD_DOCKER_REPO:$CD_REF_NAME is being published"
80
-docker push $CD_DOCKER_REPO
81
-
82
-# Publish image as latest and v2 if it is a release (excluding alpha and beta)
83
-if [[ "$CD_REF_NAME" == *"v"* ]] && [[ "$CD_REF_NAME" != *"alpha"* ]] && [[ "$CD_REF_NAME" != *"beta"* ]]; then
84
-  docker_image_id=$(docker images | grep -E "^$CD_DOCKER_REPO.*$CD_REF_NAME" | awk -e '{print $3}')
85
-  docker tag $docker_image_id $CD_DOCKER_REPO:latest
86
-  docker push $CD_DOCKER_REPO:latest
87
-  docker tag $docker_image_id $CD_DOCKER_REPO:v2
88
-  docker push $CD_DOCKER_REPO:v2
89
-fi
90
-exit 0

+ 0
- 18
scripts/deploy.sh View File

@@ -1,18 +0,0 @@
1
-#!/bin/bash
2
-
3
-DIR="$(cd "$(dirname "$0")" && pwd)"
4
-STATUS="Status: Downloaded newer image for blindsidenetwks/scalelite:latest"
5
-
6
-new_status=$(sudo docker pull blindsidenetwks/scalelite:latest | grep Status:)
7
-
8
-echo $new_status
9
-
10
-if [ "$STATUS" == "$new_status" ]
11
-then
12
-  cd $DIR/..
13
-  docker-compose down
14
-  docker rmi $(docker images -f dangling=true -q)
15
-  docker-compose up -d
16
-fi
17
-
18
-exit 0

+ 0
- 9
scripts/scalelite-auto-deployer.service View File

@@ -1,9 +0,0 @@
1
-[Unit]
2
-Description=ScaleLite Auto Deployer
3
-
4
-[Service]
5
-ExecStart=/bin/bash /opt/scalelite-run/scripts/deploy.sh
6
-
7
-[Install]
8
-WantedBy=multi-user.target
9
-Alias=scalelite-auto-deployer

+ 0
- 12
scripts/scalelite-auto-deployer.timer View File

@@ -1,12 +0,0 @@
1
-[Unit]
2
-Description=Runs scalelite-deploy every minute
3
-
4
-[Timer]
5
-# Time to wait after booting before we run first time
6
-OnBootSec=1min
7
-# Time between running each consecutive time
8
-OnUnitActiveSec=1m
9
-Unit=scalelite-auto-deployer.service
10
-
11
-[Install]
12
-WantedBy=multi-user.target

+ 0
- 18
scripts/scalelite-run.service View File

@@ -1,18 +0,0 @@
1
-[Unit]
2
-Description=ScaleLite Run
3
-After=network.target
4
-After=systemd-user-sessions.service
5
-After=network-online.target
6
-
7
-[Service]
8
-ExecStart=/bin/bash /opt/scalelite-run/scripts/start.sh
9
-ExecStop=/bin/bash /opt/scalelite-run/scripts/stop.sh
10
-TimeoutSec=30
11
-Restart=on-failure
12
-RestartSec=30
13
-StartLimitInterval=350
14
-StartLimitBurst=10
15
-
16
-[Install]
17
-WantedBy=multi-user.target
18
-Alias=scalelite-run

+ 0
- 6
scripts/start.sh View File

@@ -1,6 +0,0 @@
1
-#!/bin/bash
2
-
3
-DIR="$(cd "$(dirname "$0")" && pwd)"
4
-
5
-cd $DIR/..
6
-docker-compose up -d

+ 0
- 6
scripts/stop.sh View File

@@ -1,6 +0,0 @@
1
-#!/bin/bash
2
-
3
-DIR="$(cd "$(dirname "$0")" && pwd)"
4
-
5
-cd $DIR/..
6
-docker-compose down

Loading…
Cancel
Save