From 19fef3d2d43e3ad7aa32c2fd1f0cea4faa4a1bba Mon Sep 17 00:00:00 2001 From: Carlos Muniz Date: Mon, 25 Jul 2022 14:31:10 -0400 Subject: [PATCH] feat: add COMPOSE_MOUNTS for edx-notes-api Co-authored-by: Carlos Muniz --- README.rst | 9 +++++++++ tutornotes/plugin.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.rst b/README.rst index 2406ec4..e7d1d36 100644 --- a/README.rst +++ b/README.rst @@ -35,3 +35,12 @@ Configuration - ``NOTES_MYSQL_USERNAME`` (default: ``"notes"``) These values can be modified with ``tutor config save --set PARAM_NAME=VALUE`` commands. + +Debugging +--------- + +To debug the notes API service, you are encouraged to mount the edx-notes-api repo from the host in the development container: + + tutor dev start --mount /path/to/edx-notes-api + +Feel free to add breakpoints (``breakpoint()``) anywhere in your source code to debug your application. diff --git a/tutornotes/plugin.py b/tutornotes/plugin.py index bd3a8bf..e5f1d94 100644 --- a/tutornotes/plugin.py +++ b/tutornotes/plugin.py @@ -53,6 +53,20 @@ tutor_hooks.Filters.IMAGES_PUSH.add_item(( "{{ NOTES_DOCKER_IMAGE }}", )) +@tutor_hooks.Filters.COMPOSE_MOUNTS.add() +def _mount_edx_notes_api(volumes, name): + """ + When mounting edx-notes-api with `--mount=/path/to/edx-notes-api`, + bind-mount the host repo in the notes container. + """ + if name == "edx-notes-api": + path = "/app/edx-notes-api" + volumes += [ + ("notes", path), + ("notes-job", path), + ] + return volumes + ####### Boilerplate code # Add the "templates" folder as a template root tutor_hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(