From 2b7e4d3d19e895f068775fd0950e91fe2ab6892b Mon Sep 17 00:00:00 2001 From: Gernot Schulz Date: Sat, 15 Aug 2020 12:59:47 +0200 Subject: [PATCH] Docker: Add backend variables to .env and templates This setup chooses to avoid the env_file option available for Docker Compose files. Docker has a peculiar way of parsing variables which makes it, for example, include quotes verbatim. This is both confusing and incompatible with shells parsing the same file which is a requirement. For this reason, the configuration does not import the complete environment using env_file but assigns variables explicitly on a need-to-know basis in the YAML file, much like Docker secrets. Since the configuration is generated automatically, the burden on users is the same as with env_file: they only need to edit .env for customizations. --- docker/.env | 31 +++++++++++++++++++++++++++++++ docker/docker-compose.yml.m4 | 29 +++++++++++++++++++++++++++-- docker/docker-stack.yml.m4 | 29 +++++++++++++++++++++++++++-- 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/docker/.env b/docker/.env index 86d4c900e..876e249e3 100644 --- a/docker/.env +++ b/docker/.env @@ -45,3 +45,34 @@ MEDIA_SERVICE_REPLICAS= DEFAULT_FROM_EMAIL= POSTFIX_MYHOSTNAME= POSTFIX_RELAYHOST= + +# OpenSlides Backend settings (settings.py) +# ----------------------------------------- +# Features +ENABLE_SAML= +ENABLE_ELECTRONIC_VOTING= +# Connections +AUTOUPDATE_DELAY= +CONNECTION_POOL_LIMIT= +DATABASE_HOST= +DATABASE_PASSWORD= +DATABASE_PORT= +DATABASE_USER= +EMAIL_HOST= +EMAIL_HOST_PASSWORD= +EMAIL_HOST_USER= +EMAIL_PORT= +JITSI_DOMAIN= +JITSI_PASSWORD= +JITSI_ROOM_NAME= +REDIS_CHANNLES_HOST= +REDIS_CHANNLES_PORT= +REDIS_HOST= +REDIS_PORT= +REDIS_SLAVE_HOST= +REDIS_SLAVE_PORT= +REDIS_SLAVE_WAIT_TIMEOUT= +# Logging +DJANGO_LOG_LEVEL= +OPENSLIDES_LOG_LEVEL= +RESET_PASSWORD_VERBOSE_ERRORS= diff --git a/docker/docker-compose.yml.m4 b/docker/docker-compose.yml.m4 index 1d001d5a2..b88a442b6 100644 --- a/docker/docker-compose.yml.m4 +++ b/docker/docker-compose.yml.m4 @@ -43,9 +43,34 @@ x-osserver: - back restart: always x-osserver-env: &default-osserver-env - INSTANCE_DOMAIN: "ifenvelse(`INSTANCE_DOMAIN', http://example.com:8000)" + AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 1) + AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1) + CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100) + DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)" + DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)" + DATABASE_PORT: ifenvelse(`DATABASE_PORT', 5432) + DATABASE_USER: "ifenvelse(`DATABASE_USER', openslides)" DEFAULT_FROM_EMAIL: "ifenvelse(`DEFAULT_FROM_EMAIL', noreply@example.com)" - REDIS_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 1) + DJANGO_LOG_LEVEL: "ifenvelse(`DJANGO_LOG_LEVEL', INFO)" + EMAIL_HOST: "ifenvelse(`EMAIL_HOST', postfix)" + EMAIL_HOST_PASSWORD: "ifenvelse(`EMAIL_HOST_PASSWORD',)" + EMAIL_HOST_USER: "ifenvelse(`EMAIL_HOST_USER',)" + EMAIL_PORT: ifenvelse(`EMAIL_PORT', 25) + ENABLE_ELECTRONIC_VOTING: "ifenvelse(`ENABLE_ELECTRONIC_VOTING', False)" + ENABLE_SAML: "ifenvelse(`ENABLE_SAML', False)" + INSTANCE_DOMAIN: "ifenvelse(`INSTANCE_DOMAIN', http://example.com:8000)" + JITSI_DOMAIN: "ifenvelse(`JITSI_DOMAIN', None)" + JITSI_PASSWORD: "ifenvelse(`JITSI_PASSWORD', None)" + JITSI_ROOM_NAME: "ifenvelse(`JITSI_ROOM_NAME', None)" + OPENSLIDES_LOG_LEVEL: "ifenvelse(`OPENSLIDES_LOG_LEVEL', INFO)" + REDIS_CHANNLES_HOST: "ifenvelse(`REDIS_CHANNLES_HOST', redis-channels)" + REDIS_CHANNLES_PORT: ifenvelse(`REDIS_CHANNLES_PORT', 6379) + REDIS_HOST: "ifenvelse(`REDIS_HOST', redis)" + REDIS_PORT: ifenvelse(`REDIS_PORT', 6379) + REDIS_SLAVE_HOST: "ifenvelse(`REDIS_SLAVE_HOST', redis-slave)" + REDIS_SLAVE_PORT: ifenvelse(`REDIS_SLAVE_PORT', 6379) + REDIS_SLAVE_WAIT_TIMEOUT: ifenvelse(`REDIS_SLAVE_WAIT_TIMEOUT', 10000) + RESET_PASSWORD_VERBOSE_ERRORS: "ifenvelse(`RESET_PASSWORD_VERBOSE_ERRORS', False)" x-pgnode: &default-pgnode image: ifenvelse(`DEFAULT_DOCKER_REGISTRY', openslides)/openslides-repmgr:latest networks: diff --git a/docker/docker-stack.yml.m4 b/docker/docker-stack.yml.m4 index 191e8aacf..a39c42232 100644 --- a/docker/docker-stack.yml.m4 +++ b/docker/docker-stack.yml.m4 @@ -42,9 +42,34 @@ x-osserver: - front - back x-osserver-env: &default-osserver-env - INSTANCE_DOMAIN: "ifenvelse(`INSTANCE_DOMAIN', http://example.com:8000)" + AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 3) + AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1) + CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100) + DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)" + DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)" + DATABASE_PORT: ifenvelse(`DATABASE_PORT', 5432) + DATABASE_USER: "ifenvelse(`DATABASE_USER', openslides)" DEFAULT_FROM_EMAIL: "ifenvelse(`DEFAULT_FROM_EMAIL', noreply@example.com)" - REDIS_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 3) + DJANGO_LOG_LEVEL: "ifenvelse(`DJANGO_LOG_LEVEL', INFO)" + EMAIL_HOST: "ifenvelse(`EMAIL_HOST', postfix)" + EMAIL_HOST_PASSWORD: "ifenvelse(`EMAIL_HOST_PASSWORD',)" + EMAIL_HOST_USER: "ifenvelse(`EMAIL_HOST_USER',)" + EMAIL_PORT: ifenvelse(`EMAIL_PORT', 25) + ENABLE_ELECTRONIC_VOTING: "ifenvelse(`ENABLE_ELECTRONIC_VOTING', False)" + ENABLE_SAML: "ifenvelse(`ENABLE_SAML', False)" + INSTANCE_DOMAIN: "ifenvelse(`INSTANCE_DOMAIN', http://example.com:8000)" + JITSI_DOMAIN: "ifenvelse(`JITSI_DOMAIN', None)" + JITSI_PASSWORD: "ifenvelse(`JITSI_PASSWORD', None)" + JITSI_ROOM_NAME: "ifenvelse(`JITSI_ROOM_NAME', None)" + OPENSLIDES_LOG_LEVEL: "ifenvelse(`OPENSLIDES_LOG_LEVEL', INFO)" + REDIS_CHANNLES_HOST: "ifenvelse(`REDIS_CHANNLES_HOST', redis-channels)" + REDIS_CHANNLES_PORT: ifenvelse(`REDIS_CHANNLES_PORT', 6379) + REDIS_HOST: "ifenvelse(`REDIS_HOST', redis)" + REDIS_PORT: ifenvelse(`REDIS_PORT', 6379) + REDIS_SLAVE_HOST: "ifenvelse(`REDIS_SLAVE_HOST', redis-slave)" + REDIS_SLAVE_PORT: ifenvelse(`REDIS_SLAVE_PORT', 6379) + REDIS_SLAVE_WAIT_TIMEOUT: ifenvelse(`REDIS_SLAVE_WAIT_TIMEOUT', 10000) + RESET_PASSWORD_VERBOSE_ERRORS: "ifenvelse(`RESET_PASSWORD_VERBOSE_ERRORS', False)" x-pgnode: &default-pgnode image: ifenvelse(`DEFAULT_DOCKER_REGISTRY', openslides)/openslides-repmgr:latest networks: