|
| 1 | +# run-mooc-jutut |
| 2 | + |
| 3 | +Docker container for running [MOOC-Jutut](https://github.com/apluslms/mooc-jutut). |
| 4 | +This is intended for local development and testing. |
| 5 | + |
| 6 | +# Usage |
| 7 | + |
| 8 | +MOOC-jutut is installed in `/srv/jutut`. |
| 9 | +You can mount development version of the source code to `/src/jutut`. |
| 10 | +The container will then copy it to `/srv/jutut` and compile |
| 11 | +the translation file (django.mo). If you mount directly to |
| 12 | +`/srv/jutut`, you need to manually compile the translation file beforehand, |
| 13 | +but on the other hand, Django can reload the code and restart the server |
| 14 | +without restarting the whole container when you edit the source code files. |
| 15 | + |
| 16 | +You can mount development version of the MOOC-Jutut source code on top of that, if you wish. |
| 17 | + |
| 18 | +Location `/data` is a volume and contains the database and secret key. |
| 19 | +It is world writable, so you can run this container as normal user. |
| 20 | + |
| 21 | +You may enable the [Django Debug Toolbar](https://pypi.org/project/django-debug-toolbar/) |
| 22 | +(a set of panels in the web browser that display useful debug information) |
| 23 | +by setting the Django setting `ENABLE_DJANGO_DEBUG_TOOLBAR` to `True`. |
| 24 | +It is easy to do that via the environment variable `JUTUT_ENABLE_DJANGO_DEBUG_TOOLBAR`. |
| 25 | +See the `docker-compose.yml` example below. |
| 26 | + |
| 27 | +Using the VS Code Python debugger is easy with the container. |
| 28 | +VS Code can attach to the container even when VS Code is running in the host machine |
| 29 | +and the Jutut app inside a container. In the `docker-compose.yml` example below, |
| 30 | +the `command` starts debugpy inside the container. |
| 31 | +The VS Code debugging settings are given in the `launch.json` example further below. |
| 32 | + |
| 33 | +Partial example of `docker-compose.yml` (volumes are optional of course): |
| 34 | + |
| 35 | +```yaml |
| 36 | +services: |
| 37 | + jutut: |
| 38 | + image: apluslms/run-mooc-jutut:3.1 |
| 39 | + # Start debugpy when you want to debug remotely in VS Code. |
| 40 | + #command: "python3 -m debugpy --wait-for-client --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8082" |
| 41 | + #command: "python3 -m debugpy --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8082" |
| 42 | + environment: |
| 43 | + JUTUT_ENABLE_DJANGO_DEBUG_TOOLBAR: 'false' |
| 44 | + volumes: |
| 45 | + # named persistent volume (until removed) |
| 46 | + - data:/data |
| 47 | + # mount development version to /src/jutut |
| 48 | + #- /home/user/mooc-jutut/:/src/jutut/:ro |
| 49 | + # or to /srv/jutut |
| 50 | + #- /home/user/mooc-jutut/:/srv/jutut/:ro |
| 51 | + ports: |
| 52 | + - "8082:8082" |
| 53 | + # port 5678 inside the container is used by debugpy (VS Code debugger) |
| 54 | + - "5677:5678" |
| 55 | + |
| 56 | + grader: |
| 57 | + image: apluslms/run-mooc-grader:1.31 |
| 58 | + #command: "python3 -m debugpy --wait-for-client --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8080" |
| 59 | + volumes: |
| 60 | + - data:/data |
| 61 | + - /var/run/docker.sock:/var/run/docker.sock |
| 62 | + - /tmp/aplus:/tmp/aplus |
| 63 | + # mount a course directory |
| 64 | + #- $HOME/courses/aplus-manual:/srv/courses/default:ro |
| 65 | + #- $HOME/mooc-grader/:/srv/grader/:ro |
| 66 | + ports: |
| 67 | + - "8080:8080" |
| 68 | + - "5679:5678" |
| 69 | + plus: |
| 70 | + image: apluslms/run-aplus-front:1.31 |
| 71 | + #command: "python3 -m debugpy --wait-for-client --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000" |
| 72 | + environment: |
| 73 | + APLUS_ENABLE_DJANGO_DEBUG_TOOLBAR: 'false' |
| 74 | + volumes: |
| 75 | + - data:/data |
| 76 | + #- $HOME/a-plus/:/srv/aplus/:ro |
| 77 | + ports: |
| 78 | + - "8000:8000" |
| 79 | + - "5678:5678" |
| 80 | + depends_on: |
| 81 | + - grader |
| 82 | + |
| 83 | +volumes: |
| 84 | + data: |
| 85 | +``` |
| 86 | +
|
| 87 | +VS Code debugger settings `launch.json`. |
| 88 | +Place in `mooc-jutut/.vscode/launch.json` (in the mooc-jutut source code directory). |
| 89 | + |
| 90 | +``` |
| 91 | +{ |
| 92 | + // Use IntelliSense to learn about possible attributes. |
| 93 | + // Hover to view descriptions of existing attributes. |
| 94 | + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
| 95 | + "version": "0.2.0", |
| 96 | + "configurations": [ |
| 97 | + { |
| 98 | + "name": "Remote Attach: Jutut Python", |
| 99 | + "type": "python", |
| 100 | + "request": "attach", |
| 101 | + "connect": { |
| 102 | + "host": "localhost", |
| 103 | + "port": 5677 |
| 104 | + }, |
| 105 | + "pathMappings": [ |
| 106 | + { |
| 107 | + "localRoot": "${workspaceFolder}", |
| 108 | + "remoteRoot": "/srv/jutut" |
| 109 | + } |
| 110 | + ], |
| 111 | + "justMyCode": false |
| 112 | + } |
| 113 | + ] |
| 114 | +} |
| 115 | +``` |
0 commit comments