7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-05-30 04:40:49 +00:00

Add portainer as an optional feature

This commit is contained in:
Régis Behmo 2018-09-29 15:09:19 +02:00
parent e5ce0c9a4c
commit f85b0abac4
9 changed files with 108 additions and 35 deletions

View File

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

View File

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

View File

@ -63,6 +63,14 @@ You should beware that the `notes.<LMS_HOST>` 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:

View File

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

View File

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

View File

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

View File

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

1
data/.gitignore vendored
View File

@ -7,5 +7,6 @@ lms_worker/
elasticsearch/
mysql/
mongodb/
portainer/
rabbitmq/
xqueue/

View File

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