From 259b8961c88b4a1adcede3784ef380d8d8b49f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 20 Mar 2019 18:45:09 +0100 Subject: [PATCH] Pluggable SMTP service This is part of #114 --- CHANGELOG.md | 4 ++++ cloud/aws.sh | 6 +++--- docs/configuration.rst | 6 ++++++ tutor/images.py | 2 +- tutor/templates/apps/openedx/config/cms.env.json | 3 ++- tutor/templates/apps/openedx/config/lms.env.json | 3 ++- tutor/templates/config-defaults.yml | 5 ++++- tutor/templates/k8s/deployments.yml | 2 ++ tutor/templates/k8s/services.yml | 2 ++ tutor/templates/local/docker-compose.yml | 2 +- 10 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86e579e..9670368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Latest + +- [Feature] Configurable and pluggable data storage backends (#114) + ## 3.2.1 (2019-03-19) - [Feature] Enable grade downloads by default (#143) diff --git a/cloud/aws.sh b/cloud/aws.sh index 48395a7..54f0705 100755 --- a/cloud/aws.sh +++ b/cloud/aws.sh @@ -41,16 +41,16 @@ tutor images pull elasticsearch tutor images pull memcached tutor images pull mongodb tutor images pull mysql -tutor images pull namshi tutor images pull nginx tutor images pull rabbitmq +tutor images pull smtp echo "=============== Tagging vendor docker images" docker tag $(tutor config printvalue DOCKER_IMAGE_ELASTICSEARCH) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_ELASTICSEARCH) docker tag $(tutor config printvalue DOCKER_IMAGE_MEMCACHED) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_MEMCACHED) docker tag $(tutor config printvalue DOCKER_IMAGE_MONGODB) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_MONGODB) docker tag $(tutor config printvalue DOCKER_IMAGE_MYSQL) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_MYSQL) -docker tag $(tutor config printvalue DOCKER_IMAGE_NAMSHI) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_NAMSHI) +docker tag $(tutor config printvalue DOCKER_IMAGE_SMTP) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_SMTP) docker tag $(tutor config printvalue DOCKER_IMAGE_NGINX) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_NGINX) docker tag $(tutor config printvalue DOCKER_IMAGE_RABBITMQ) localhost:5000/$(tutor config printvalue DOCKER_IMAGE_RABBITMQ) @@ -59,7 +59,7 @@ docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_ELASTICSEARCH) docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_MEMCACHED) docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_MONGODB) docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_MYSQL) -docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_NAMSHI) +docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_SMTP) docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_NGINX) docker push localhost:5000/$(tutor config printvalue DOCKER_IMAGE_RABBITMQ) diff --git a/docs/configuration.rst b/docs/configuration.rst index 8ba5d1d..0c977b0 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -95,6 +95,12 @@ Rabbitmq - ``RABBITMQ_HOST`` (default: ``"rabbitmq"``) +SMTP +~~~~ + +- ``SMTP_HOST`` (default: ``"smtp"``) +- ``SMTP_PORT`` (default: ``25``) + Optional features ----------------- diff --git a/tutor/images.py b/tutor/images.py index 8ea6bc0..5808e43 100644 --- a/tutor/images.py +++ b/tutor/images.py @@ -11,7 +11,7 @@ def images(): pass OPENEDX_IMAGES = ["openedx", "forum", "notes", "xqueue", "android"] -VENDOR_IMAGES = ["elasticsearch", "memcached", "mongodb", "mysql", "namshi", "nginx", "rabbitmq"] +VENDOR_IMAGES = ["elasticsearch", "memcached", "mongodb", "mysql", "nginx", "rabbitmq", "smtp"] argument_openedx_image = click.argument( "image", type=click.Choice(["all"] + OPENEDX_IMAGES), ) diff --git a/tutor/templates/apps/openedx/config/cms.env.json b/tutor/templates/apps/openedx/config/cms.env.json index 46a3d4d..7d8d983 100644 --- a/tutor/templates/apps/openedx/config/cms.env.json +++ b/tutor/templates/apps/openedx/config/cms.env.json @@ -26,7 +26,8 @@ "port": {{ ELASTICSEARCH_PORT }} }], "EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend", - "EMAIL_HOST": "smtp", + "EMAIL_HOST": "{{ SMTP_HOST }}", + "EMAIL_PORT": {{ SMTP_PORT }}, "LANGUAGE_CODE": "{{ LANGUAGE_CODE }}", "CACHES": { "default": { diff --git a/tutor/templates/apps/openedx/config/lms.env.json b/tutor/templates/apps/openedx/config/lms.env.json index 00fd717..4ef3746 100644 --- a/tutor/templates/apps/openedx/config/lms.env.json +++ b/tutor/templates/apps/openedx/config/lms.env.json @@ -33,7 +33,8 @@ "port": {{ ELASTICSEARCH_PORT }} }], "EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend", - "EMAIL_HOST": "smtp", + "EMAIL_HOST": "{{ SMTP_HOST }}", + "EMAIL_PORT": {{ SMTP_PORT }}, {% if ACTIVATE_NOTES %} "EDXNOTES_PUBLIC_API": "{{ "https" if ACTIVATE_HTTPS else "http" }}://notes.{{ LMS_HOST }}/api/v1", "EDXNOTES_INTERNAL_API": "http://notes.openedx:8000/api/v1", diff --git a/tutor/templates/config-defaults.yml b/tutor/templates/config-defaults.yml index ca8179a..78d0a9f 100644 --- a/tutor/templates/config-defaults.yml +++ b/tutor/templates/config-defaults.yml @@ -4,6 +4,7 @@ ACTIVATE_MEMCACHED: true ACTIVATE_MONGODB: true ACTIVATE_MYSQL: true ACTIVATE_RABBITMQ: true +ACTIVATE_SMTP: true ANDROID_RELEASE_STORE_PASSWORD: "android store password" ANDROID_RELEASE_KEY_PASSWORD: "android release key password" ANDROID_RELEASE_KEY_ALIAS: "android release key alias" @@ -18,7 +19,7 @@ DOCKER_IMAGE_MYSQL: "mysql:5.6.36" DOCKER_IMAGE_ELASTICSEARCH: "elasticsearch:1.5.2" DOCKER_IMAGE_NGINX: "nginx:1.13" DOCKER_IMAGE_RABBITMQ: "rabbitmq:3.6.10" -DOCKER_IMAGE_NAMSHI: "namshi/smtp:latest" +DOCKER_IMAGE_SMTP: "namshi/smtp:latest" DOCKER_REGISTRY: "" ELASTICSEARCH_HOST: "elasticsearch" ELASTICSEARCH_PORT: 9200 @@ -35,6 +36,8 @@ NGINX_HTTPS_PORT: 443 NOTES_MYSQL_DATABASE: "notes" NOTES_MYSQL_USERNAME: "notes" RABBITMQ_HOST: "rabbitmq" +SMTP_HOST: "smtp" +SMTP_PORT: 25 XQUEUE_AUTH_USERNAME: "lms" XQUEUE_MYSQL_DATABASE: "xqueue" XQUEUE_MYSQL_USERNAME: "xqueue" diff --git a/tutor/templates/k8s/deployments.yml b/tutor/templates/k8s/deployments.yml index 6bf5951..be46f93 100644 --- a/tutor/templates/k8s/deployments.yml +++ b/tutor/templates/k8s/deployments.yml @@ -242,6 +242,7 @@ spec: claimName: mysql {% endif %} +{% if ACTIVATE_SMTP %} --- apiVersion: apps/v1 kind: Deployment @@ -262,6 +263,7 @@ spec: image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_SMTP }} ports: - containerPort: 25 +{% endif %} --- apiVersion: apps/v1 diff --git a/tutor/templates/k8s/services.yml b/tutor/templates/k8s/services.yml index a9cb39a..f582702 100644 --- a/tutor/templates/k8s/services.yml +++ b/tutor/templates/k8s/services.yml @@ -131,6 +131,7 @@ spec: app: rabbitmq {% endif %} +{% if ACTIVATE_SMTP %} --- apiVersion: v1 kind: Service @@ -143,3 +144,4 @@ spec: protocol: TCP selector: app: smtp +{% endif %} diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index 5c3a7be..9092ac9 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -78,7 +78,7 @@ services: # Simple SMTP server smtp: - image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_NAMSHI }} + image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_SMTP }} restart: unless-stopped ############# Forum