template based generation of docker-compose.yml #71 #42

This commit is contained in:
chandi 2021-02-11 15:33:49 +01:00
parent 2a22f37706
commit 16df9ab334
14 changed files with 193 additions and 190 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -16,5 +16,5 @@ if [ ! "$ENABLE_RECORDING" == true ]; then
exit 1
fi
./scripts/compose exec recordings bbb-record $@
./scripts/compose logs --tail=15 recordings
docker-compose exec recordings bbb-record $@
docker-compose logs --tail=15 recordings

View File

@ -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 $@

View File

@ -3,4 +3,4 @@ set -e
cd $(dirname $0)/..
./scripts/compose exec freeswitch fs_cli -H 10.7.7.1
docker-compose exec freeswitch fs_cli -H 10.7.7.1

49
scripts/generate-compose Executable file
View File

@ -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

View File

@ -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"
echo " $ docker-compose up -d"

View File

@ -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