diff --git a/docker-compose.coturn.yml b/docker-compose.coturn.yml deleted file mode 100644 index 6485378..0000000 --- a/docker-compose.coturn.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3.6' -services: - coturn: - image: instrumentisto/coturn:4.5 - restart: unless-stopped - command: - - "--external-ip=${EXTERNAL_IPv4}/${EXTERNAL_IPv4}" - - "--external-ip=${EXTERNAL_IPv6:-::1}/${EXTERNAL_IPv6:-::1}" - - "--static-auth-secret=${TURN_SECRET}" - volumes: - - ssl_data:/etc/resty-auto-ssl - - ./mod/coturn/entrypoint.sh:/usr/local/bin/docker-entrypoint.sh - - ./mod/coturn/turnserver.conf:/etc/coturn/turnserver.conf - network_mode: host - -volumes: - ssl_data: - name: ssl_data \ No newline at end of file diff --git a/docker-compose.demo.yml b/docker-compose.demo.yml deleted file mode 100644 index 6249114..0000000 --- a/docker-compose.demo.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: '3.6' - -services: - demo: - build: mod/demo - environment: - DOMAIN: ${DOMAIN} - SHARED_SECRET: ${SHARED_SECRET} - ports: - - 10.7.7.1:8001:8080 \ No newline at end of file diff --git a/docker-compose.greenlight.yml b/docker-compose.greenlight.yml deleted file mode 100644 index bfbd495..0000000 --- a/docker-compose.greenlight.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: '3.6' - -services: - greenlight: - image: bigbluebutton/greenlight:v2 - restart: unless-stopped - env_file: .env - environment: - DB_ADAPTER: postgresql - DB_HOST: postgres - DB_NAME: greenlight - DB_USERNAME: postgres - DB_PASSWORD: password - BIGBLUEBUTTON_ENDPOINT: ${GREENLIGHT_ENDPOINT} - BIGBLUEBUTTON_SECRET: ${SHARED_SECRET} - SECRET_KEY_BASE: ${RAILS_SECRET} - ports: - - 10.7.7.1:5000:80 - postgres: - image: postgres:12-alpine - restart: unless-stopped - environment: - POSTGRES_DB: greenlight - POSTGRES_USER: postgres - POSTGRES_PASSWORD: password - volumes: - - ./postgres-data:/var/lib/postgresql/data diff --git a/docker-compose.https.yml b/docker-compose.https.yml deleted file mode 100644 index 4ed824f..0000000 --- a/docker-compose.https.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '3.6' -services: - https_proxy: - image: valian/docker-nginx-auto-ssl - restart: unless-stopped - volumes: - - ssl_data:/etc/resty-auto-ssl - - ./mod/https/${HTTPS_SITE_FILE}:/etc/nginx/conf.d/bbb-docker.conf - environment: - ALLOWED_DOMAINS: ${CERTIFICATE_DOMAINS} - network_mode: host - -volumes: - ssl_data: - name: ssl_data diff --git a/docker-compose.prometheus.yml b/docker-compose.prometheus.yml deleted file mode 100644 index b05de89..0000000 --- a/docker-compose.prometheus.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '3.6' - -services: - prometheus-exporter: - image: greenstatic/bigbluebutton-exporter:v0.6.0 - restart: unless-stopped - environment: - API_BASE_URL: http://10.7.7.1:8080/bigbluebutton/api/ - API_SECRET: ${SHARED_SECRET} - RECORDINGS_METRICS_READ_FROM_DISK: "false" - networks: - bbb-net: - ipv4_address: 10.7.7.33 - # volumes: - # - bigbluebutton:/var/bigbluebutton \ No newline at end of file diff --git a/docker-compose.recordings.yml b/docker-compose.recordings.yml deleted file mode 100644 index dbfdf5a..0000000 --- a/docker-compose.recordings.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3.6' -services: - recordings: - build: mod/recordings - depends_on: - - redis - environment: - DOMAIN: ${DOMAIN} - volumes: - - bigbluebutton:/var/bigbluebutton - - vol-freeswitch:/var/freeswitch/meetings - - vol-kurento:/var/kurento - tmpfs: - - /var/log/bigbluebutton - - /tmp - networks: - bbb-net: - ipv4_address: 10.7.7.16 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.tmpl.yml similarity index 62% rename from docker-compose.yml rename to docker-compose.tmpl.yml index 4bff075..de0b342 100644 --- a/docker-compose.yml +++ b/docker-compose.tmpl.yml @@ -1,3 +1,8 @@ +{{/* if you read this, you can ignore the following lines */}} +# auto generated by ./scripts/generate +# don't edit this directly. +{{/* -------- */}} + version: '3.6' services: @@ -207,12 +212,134 @@ services: bbb-net: ipv4_address: 10.7.7.12 +{{ if isTrue .Env.ENABLE_RECORDING }} + # recordings + recordings: + build: mod/recordings + depends_on: + - redis + environment: + DOMAIN: ${DOMAIN} + volumes: + - bigbluebutton:/var/bigbluebutton + - vol-freeswitch:/var/freeswitch/meetings + - vol-kurento:/var/kurento + tmpfs: + - /var/log/bigbluebutton + - /tmp + networks: + bbb-net: + ipv4_address: 10.7.7.16 +{{end}} + +{{ if isTrue .Env.ENABLE_WEBHOOKS }} + # webhooks + webhooks: + build: mod/webhooks + restart: unless-stopped + environment: + DOMAIN: ${DOMAIN} + SHARED_SECRET: ${SHARED_SECRET} + depends_on: + - redis + networks: + bbb-net: + ipv4_address: 10.7.7.17 +{{end}} + +{{ if isTrue .Env.ENABLE_HTTPS_PROXY }} + # https + https_proxy: + image: valian/docker-nginx-auto-ssl + restart: unless-stopped + volumes: + - ssl_data:/etc/resty-auto-ssl + {{ if .Env.EXTERNAL_IPv6 }} + - ./mod/https/site.conf:/etc/nginx/conf.d/bbb-docker.conf + {{else}} + - ./mod/https/site-ipv4only.conf:/etc/nginx/conf.d/bbb-docker.conf + {{end}} + environment: + {{ if not .Env.DEV_MODE }} + ALLOWED_DOMAINS: ${DOMAIN} + {{else}} + ALLOWED_DOMAINS: "" + {{end}} + network_mode: host +{{end}} + +{{ if isTrue .Env.ENABLE_COTURN }} + # coturn + coturn: + image: instrumentisto/coturn:4.5 + restart: unless-stopped + command: + - "--external-ip=${EXTERNAL_IPv4}/${EXTERNAL_IPv4}" + - "--external-ip=${EXTERNAL_IPv6:-::1}/${EXTERNAL_IPv6:-::1}" + - "--static-auth-secret=${TURN_SECRET}" + volumes: + - ssl_data:/etc/resty-auto-ssl + - ./mod/coturn/entrypoint.sh:/usr/local/bin/docker-entrypoint.sh + - ./mod/coturn/turnserver.conf:/etc/coturn/turnserver.conf + network_mode: host + +{{end}} + +{{ if isTrue .Env.ENABLE_GREENLIGHT }} + # greenlight + greenlight: + image: bigbluebutton/greenlight:v2 + restart: unless-stopped + env_file: .env + environment: + DB_ADAPTER: postgresql + DB_HOST: postgres + DB_NAME: greenlight + DB_USERNAME: postgres + DB_PASSWORD: password + {{ if isTrue .Env.DEV_MODE }} + BIGBLUEBUTTON_ENDPOINT: http://10.7.7.1:8080/bigbluebutton/api/ + {{else}} + BIGBLUEBUTTON_ENDPOINT: https://${DOMAIN}/bigbluebutton/api/ + {{end}} + BIGBLUEBUTTON_SECRET: ${SHARED_SECRET} + SECRET_KEY_BASE: ${RAILS_SECRET} + ports: + - 10.7.7.1:5000:80 + postgres: + image: postgres:12-alpine + restart: unless-stopped + environment: + POSTGRES_DB: greenlight + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + volumes: + - ./postgres-data:/var/lib/postgresql/data +{{end}} + +{{ if isTrue .Env.ENABLE_PROMETHEUS_EXPORTER }} + # prometheus + prometheus-exporter: + image: greenstatic/bigbluebutton-exporter:v0.6.0 + restart: unless-stopped + environment: + API_BASE_URL: http://10.7.7.1:8080/bigbluebutton/api/ + API_SECRET: ${SHARED_SECRET} + RECORDINGS_METRICS_READ_FROM_DISK: "false" + networks: + bbb-net: + ipv4_address: 10.7.7.33 +{{end}} + volumes: bigbluebutton: vol-freeswitch: vol-kurento: html5-static: vol-libreoffice: +{{ if isTrue .Env.ENABLE_HTTPS_PROXY }} + ssl_data: +{{end}} networks: bbb-net: diff --git a/docker-compose.webhooks.yml b/docker-compose.webhooks.yml deleted file mode 100644 index 396ef56..0000000 --- a/docker-compose.webhooks.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: '3.6' -services: - webhooks: - build: mod/webhooks - restart: unless-stopped - environment: - DOMAIN: ${DOMAIN} - SHARED_SECRET: ${SHARED_SECRET} - depends_on: - - redis - networks: - bbb-net: - ipv4_address: 10.7.7.17 \ No newline at end of file diff --git a/scripts/bbb-record b/scripts/bbb-record index 64ec423..3814956 100755 --- a/scripts/bbb-record +++ b/scripts/bbb-record @@ -16,5 +16,5 @@ if [ ! "$ENABLE_RECORDING" == true ]; then exit 1 fi -./scripts/compose exec recordings bbb-record $@ -./scripts/compose logs --tail=15 recordings \ No newline at end of file +docker-compose exec recordings bbb-record $@ +docker-compose logs --tail=15 recordings \ No newline at end of file diff --git a/scripts/compose b/scripts/compose deleted file mode 100755 index a560126..0000000 --- a/scripts/compose +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -set -e - -cd $(dirname $0)/.. - -# load .env -if [ -f .env ] -then - # exclude WELCOME_MESSAGE && WELCOME_FOOTER because it may contain invalid characters - export $(cat .env | sed 's/#.*//g' | grep -v "WELCOME_FOOTER" | grep -v "WELCOME_MESSAGE" | xargs) -fi - -# check for non-optional environment variables, -# which got introduced later and may miss in existing -# .env files during upgrades -if [ -z "$EXTERNAL_IPv4" ]; then - echo "ERROR: EXTERNAL_IPv4 is not set in .env" - echo "BBB won't work without it." - echo "this can happen if you did an manual upgrade without executing" - echo " ./scripts/upgrade" - echo "try to run it again" - exit 1 -fi - -# set conditional variables -export CERTIFICATE_DOMAINS=$DOMAIN -export GREENLIGHT_ENDPOINT=https://$DOMAIN/bigbluebutton/api/ -if [ "$DEV_MODE" == true ]; then - export CERTIFICATE_DOMAINS="invalid" - export GREENLIGHT_ENDPOINT=http://10.7.7.1:8080/bigbluebutton/api/ -fi -if [ ! -z "$EXTERNAL_IPv6" ]; then - export HTTPS_SITE_FILE="site.conf" -else - export HTTPS_SITE_FILE="site-ipv4only.conf" -fi - -# concatenate docker-compose file -COMPOSE_FILES="-f docker-compose.yml" -if [ "$ENABLE_HTTPS_PROXY" == true ]; then - COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.https.yml" -fi - -if [ "$ENABLE_COTURN" == true ]; then - COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.coturn.yml" -fi - -if [ "$ENABLE_GREENLIGHT" == true ]; then - COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.greenlight.yml" -fi - -if [ "$ENABLE_WEBHOOKS" == true ]; then - COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.webhooks.yml" -fi - -if [ "$ENABLE_PROMETHEUS_EXPORTER" == true ]; then - COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.prometheus.yml" -fi - -if [ "$ENABLE_RECORDING" == true ]; then - COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.recordings.yml" -fi - -docker-compose $COMPOSE_FILES $@ diff --git a/scripts/fs_cli b/scripts/fs_cli index bd50e2c..53a79f6 100755 --- a/scripts/fs_cli +++ b/scripts/fs_cli @@ -3,4 +3,4 @@ set -e cd $(dirname $0)/.. -./scripts/compose exec freeswitch fs_cli -H 10.7.7.1 \ No newline at end of file +docker-compose exec freeswitch fs_cli -H 10.7.7.1 \ No newline at end of file diff --git a/scripts/generate-compose b/scripts/generate-compose new file mode 100755 index 0000000..c020e70 --- /dev/null +++ b/scripts/generate-compose @@ -0,0 +1,49 @@ +#!/bin/bash +set -e + +cd $(dirname $0)/.. + +# load .env +if [ -f .env ] +then + # exclude WELCOME_MESSAGE && WELCOME_FOOTER because it may contain invalid characters + export $(cat .env | sed 's/#.*//g' | grep -v "WELCOME_FOOTER" | grep -v "WELCOME_MESSAGE" | xargs) +fi + +# check for non-optional environment variables, +# which got introduced later and may miss in existing +# .env files during upgrades +if [ -z "$EXTERNAL_IPv4" ]; then + echo "ERROR: EXTERNAL_IPv4 is not set in .env" + echo "BBB won't work without it." + exit 1 +fi + +if [ "$ENABLE_COTURN" == true ]; then + if [ -z "$ENABLE_HTTPS_PROXY" ]; then + echo "ERROR: coturn requires the https proxy for certificate retrival." + echo "you must also set ENABLE_HTTPS_PROXY=true" + exit 1 + fi + if [ "$DEV_MODE" == true ]; then + echo "ERROR: the https proxy can't get a certificate if ran locally and therefor coturn will never start" + echo "you should disable coturn in .env" + exit 1 + fi +fi + + + + +docker run \ + --rm \ + -v $(pwd)/docker-compose.tmpl.yml:/docker-compose.tmpl.yml \ + -e DEV_MODE=${DEV_MODE:-false} \ + -e ENABLE_RECORDING=${ENABLE_RECORDING:-false} \ + -e ENABLE_HTTPS_PROXY=${ENABLE_HTTPS_PROXY:-false} \ + -e ENABLE_WEBHOOKS=${ENABLE_WEBHOOKS:-false} \ + -e ENABLE_COTURN=${ENABLE_COTURN:-false} \ + -e ENABLE_GREENLIGHT=${ENABLE_GREENLIGHT:-false} \ + -e ENABLE_PROMETHEUS_EXPORTER=${ENABLE_PROMETHEUS_EXPORTER:-false} \ + jwilder/dockerize -template /docker-compose.tmpl.yml \ + > docker-compose.yml \ No newline at end of file diff --git a/scripts/setup b/scripts/setup index 04fe462..d062b82 100755 --- a/scripts/setup +++ b/scripts/setup @@ -127,11 +127,16 @@ sed -i "s/SHARED_SECRET=.*/SHARED_SECRET=$RANDOM_1/" .env sed -i "s/ETHERPAD_API_KEY=.*/ETHERPAD_API_KEY=$RANDOM_2/" .env sed -i "s/RAILS_SECRET=.*/RAILS_SECRET=$RANDOM_3/" .env +./scripts/generate-compose + echo "--------------------------------------------------" echo "configuration file .env got successfully created!" echo "" echo "you can look through it for further adjusments" echo " $ nano .env" echo "" +echo "make sure to recreate the docker-compose.yml after each change" +echo " $ ./scripts/generate-compose" +echo "" echo "to start bigbluebutton run" -echo " $ ./scripts/compose up -d" \ No newline at end of file +echo " $ docker-compose up -d" \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index f10213e..941a288 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,26 +11,28 @@ then # restart script, since it might have changed. RESTARTED=1 ./scripts/upgrade + exit else - # update changed environment variable - sed -i 's/EXTERNAL_IP=/EXTERNAL_IPv4=/' .env echo "" echo "# pull newest git submodules" git submodule init git submodule update + echo "" + echo "# recreate docker-compose.yml" + ./scripts/generate-compose echo "" echo "# pull newest images" - ./scripts/compose pull + docker-compose pull echo "" echo "# rebuild images" # rebuild everything which got modified - ./scripts/compose build --pull + docker-compose build --pull COMMIT_HASH=$(git rev-parse --short HEAD) BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) @@ -40,7 +42,7 @@ else echo "images successfully rebuilt!" echo "we are on $COMMIT_HASH ($BRANCH_NAME)" echo "" - echo "use following command for restarting:" - echo " $ ./scripts/compose up -d" + echo "use following command for restarting bbb:" + echo " $ docker-compose up -d" echo "-------------------------------------" fi \ No newline at end of file