From f85b0abac4626ba5612deef6daa9dae97c7303c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Sat, 29 Sep 2018 15:09:19 +0200 Subject: [PATCH] Add portainer as an optional feature --- CHANGELOG.md | 1 + Makefile | 5 +- README.md | 8 +++ configurator/bin/configure.py | 2 + .../templates/letsencrypt/certonly.sh | 10 ++- configurator/templates/nginx/extra.conf | 71 +++++++++++++++++++ configurator/templates/nginx/notes.conf | 33 --------- data/.gitignore | 1 + docker-compose-portainer.yml | 12 ++++ 9 files changed, 108 insertions(+), 35 deletions(-) create mode 100644 configurator/templates/nginx/extra.conf delete mode 100644 configurator/templates/nginx/notes.conf create mode 100644 docker-compose-portainer.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index e7c1a2f..8c4bb5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +- 2018-09-29 [Feature] Add [Portainer](https://portainer.io) as an optional web UI to administer docker containers - 2018-09-15 [Feature] Add student notes as an optional feature - 2018-09-15 [Feature] Add templates to configurator container, which can now be run separately - 2018-09-15 [Improvement] Rename "up" and "daemon" commands to "run" and "daemonize" diff --git a/Makefile b/Makefile index 0794a3e..c6b972d 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,9 @@ ifeq ($(ACTIVATE_NOTES), 1) extra_migrate_targets += migrate-notes DOCKER_COMPOSE += -f docker-compose-notes.yml endif +ifeq ($(ACTIVATE_PORTAINER), 1) + DOCKER_COMPOSE += -f docker-compose-portainer.yml +endif DOCKER_COMPOSE_RUN = $(DOCKER_COMPOSE) run --rm DOCKER_COMPOSE_RUN_OPENEDX = $(DOCKER_COMPOSE_RUN) -e USERID=$(USERID) -e SETTINGS=$(EDX_PLATFORM_SETTINGS) @@ -39,7 +42,7 @@ all: configure $(post_configure_targets) update migrate assets daemonize configure: build-configurator docker run --rm -it --volume="$(PWD)/config:/openedx/config" \ -e USERID=$(USERID) -e SILENT=$(SILENT) \ - -e SETTING_ACTIVATE_HTTPS=$(ACTIVATE_HTTPS) -e SETTING_ACTIVATE_NOTES=$(ACTIVATE_NOTES) -e SETTING_ACTIVATE_XQUEUE=$(ACTIVATE_XQUEUE) \ + -e SETTING_ACTIVATE_HTTPS=$(ACTIVATE_HTTPS) -e SETTING_ACTIVATE_NOTES=$(ACTIVATE_NOTES) -e SETTING_ACTIVATE_PORTAINER=$(ACTIVATE_PORTAINER) -e SETTING_ACTIVATE_XQUEUE=$(ACTIVATE_XQUEUE) \ regis/openedx-configurator:hawthorn stats: diff --git a/README.md b/README.md index 50928bb..1eb8968 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,14 @@ You should beware that the `notes.` domain name should be activated an Note: in previous releases of openedx-docker, xqueue was run for all platforms. It is now an optional feature. +### Docker container web UI with [Portainer](https://portainer.io/) (`ACTIVATE_PORTAINER`) + +Portainer is a web UI for managing docker containers. It lets you view your entire Open edX platform at a glace. Try it! It's really cool. + +![Portainer demo](https://portainer.io/images/screenshots/portainer.gif) + +After launching your platfom, the web UI will be available at [http://portainer.localhost](http://portainer.localhost) and http://portainer.YOUR_LMS_HOST. You will be asked to define a password for the admin user. Then, select a "Local environment" to work on and hit "Connect". You're done! Select the "local" group to view all running containers. Amon many other things, you'll be able to view the logs for each container, which is really useful. + ### Android app (beta) The Android app for your platform can be easily built in just one command: diff --git a/configurator/bin/configure.py b/configurator/bin/configure.py index 0288bfa..20555ba 100755 --- a/configurator/bin/configure.py +++ b/configurator/bin/configure.py @@ -158,6 +158,8 @@ def interactive(args): 'ACTIVATE_NOTES', "", False ).add_bool( 'ACTIVATE_HTTPS', "", False + ).add_bool( + 'ACTIVATE_PORTAINER', "", False ).add_bool( 'ACTIVATE_XQUEUE', "", False ).add( diff --git a/configurator/templates/letsencrypt/certonly.sh b/configurator/templates/letsencrypt/certonly.sh index 98f88a5..3568ea5 100755 --- a/configurator/templates/letsencrypt/certonly.sh +++ b/configurator/templates/letsencrypt/certonly.sh @@ -1,2 +1,10 @@ #!/bin/sh -certbot certonly --standalone -n --agree-tos -m admin@{{ LMS_HOST }} -d {{ LMS_HOST }} -d {{ CMS_HOST }} -d preview.{{ LMS_HOST }} {% if ACTIVATE_NOTES %} -d notes.{{ LMS_HOST }}{% endif %} +certbot certonly --standalone -n --agree-tos -m admin@{{ LMS_HOST }} -d {{ LMS_HOST }} -d {{ CMS_HOST }} -d preview.{{ LMS_HOST }} + +{% if ACTIVATE_NOTES %} +certbot certonly --standalone -n --agree-tos -m admin@{{ LMS_HOST }} -d notes.{{ LMS_HOST }} +{% endif %} + +{% if ACTIVATE_PORTAINER %} +certbot certonly --standalone -n --agree-tos -m admin@{{ LMS_HOST }} -d portainer.{{ LMS_HOST }} +{% endif %} diff --git a/configurator/templates/nginx/extra.conf b/configurator/templates/nginx/extra.conf new file mode 100644 index 0000000..22b4a34 --- /dev/null +++ b/configurator/templates/nginx/extra.conf @@ -0,0 +1,71 @@ +{% if ACTIVATE_NOTES %} +{% if ACTIVATE_HTTPS %} +server { + server_name notes.{{ LMS_HOST }}; + listen 80; + return 301 https://$server_name$request_uri; +} +{% endif %} + +server { + listen {{ "443 ssl" if ACTIVATE_HTTPS else "80" }}; + server_name notes.localhost notes.{{ LMS_HOST }}; + + {% if ACTIVATE_HTTPS %} + ssl_certificate /etc/letsencrypt/live/notes.{{ LMS_HOST }}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/notes.{{ LMS_HOST }}/privkey.pem; + {% endif %} + + # Disables server version feedback on pages and in headers + server_tokens off; + + location / { + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $http_host; + proxy_redirect off; + + # Docker resolver + resolver 127.0.0.11 valid=10s; + set $upstream notes; + proxy_pass http://$upstream:8000; + } +} +{% endif %} + +{% if ACTIVATE_PORTAINER %} +{% if ACTIVATE_HTTPS %} +server { + server_name portainer.{{ LMS_HOST }}; + listen 80; + return 301 https://$server_name$request_uri; +} +{% endif %} + +server { + listen {{ "443 ssl" if ACTIVATE_HTTPS else "80" }}; + server_name portainer.localhost portainer.{{ LMS_HOST }}; + + {% if ACTIVATE_HTTPS %} + ssl_certificate /etc/letsencrypt/live/portainer.{{ LMS_HOST }}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/portainer.{{ LMS_HOST }}/privkey.pem; + {% endif %} + + # Disables server version feedback on pages and in headers + server_tokens off; + + location / { + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $http_host; + proxy_redirect off; + + # Docker resolver + resolver 127.0.0.11 valid=10s; + set $upstream portainer; + proxy_pass http://$upstream:9000; + } +} +{% endif %} diff --git a/configurator/templates/nginx/notes.conf b/configurator/templates/nginx/notes.conf deleted file mode 100644 index 552eff2..0000000 --- a/configurator/templates/nginx/notes.conf +++ /dev/null @@ -1,33 +0,0 @@ -{% if ACTIVATE_HTTPS %} -server { - server_name notes.{{ LMS_HOST }}; - listen 80; - return 301 https://$server_name$request_uri; -} -{% endif %} - -server { - listen {{ "443 ssl" if ACTIVATE_HTTPS else "80" }}; - server_name notes.localhost notes.{{ LMS_HOST }}; - - {% if ACTIVATE_HTTPS %} - ssl_certificate /etc/letsencrypt/live/notes.{{ LMS_HOST }}/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/notes.{{ LMS_HOST }}/privkey.pem; - {% endif %} - - # Disables server version feedback on pages and in headers - server_tokens off; - - location / { - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header Host $http_host; - proxy_redirect off; - - # Docker resolver - resolver 127.0.0.11 valid=10s; - set $upstream notes; - proxy_pass http://$upstream:8000; - } -} diff --git a/data/.gitignore b/data/.gitignore index 4dea487..f7ff79c 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -7,5 +7,6 @@ lms_worker/ elasticsearch/ mysql/ mongodb/ +portainer/ rabbitmq/ xqueue/ diff --git a/docker-compose-portainer.yml b/docker-compose-portainer.yml new file mode 100644 index 0000000..3cebc8d --- /dev/null +++ b/docker-compose-portainer.yml @@ -0,0 +1,12 @@ +version: "3" +services: + + ############# Portainer: container supervision with a web UI + portainer: + image: portainer/portainer:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./data/portainer:/data + restart: unless-stopped + depends_on: + - nginx