From 3f0ccc65a80f1358d9b05a8412d2714034d2f7c1 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Thu, 26 Sep 2024 15:21:47 -0400 Subject: [PATCH 1/3] feat: create volume for private LMS/CMS media assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content Libraries will store asset files like images, transcripts, and PDFs using Learning Core–which in turn uses django-storages and expects some backing file store. These files should NOT be directly accessible via the browser, both because of access policies and the fact that the filenames will not be meaningful by themselves and must be translated by app logic. For details see: * https://github.com/openedx/openedx-learning/blob/main/docs/decisions/0015-serving-static-assets.rst * https://github.com/openedx/openedx-learning/blob/main/openedx_learning/apps/authoring/contents/models.py * https://github.com/openedx/openedx-learning/blob/main/openedx_learning/apps/authoring/components/models.py The existing /data/openedx-media -> /openedx/media mount is publicly accessible by browser, and so is not appropriate for this purpose. This commit creates a parallel /data/openedx-media-private -> /openedx/media-private volume mapping instead. This commit also creates configuration needed for openedx-learning to point to this new directory. This commit does NOT currently add support for this in k8s, as that will require changes to the minio plugin. --- changelog.d/20240926_151223_dave_private_media.md | 1 + .../apps/openedx/settings/partials/common_all.py | 9 +++++++++ tutor/templates/local/docker-compose.yml | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 changelog.d/20240926_151223_dave_private_media.md diff --git a/changelog.d/20240926_151223_dave_private_media.md b/changelog.d/20240926_151223_dave_private_media.md new file mode 100644 index 0000000000..20354be513 --- /dev/null +++ b/changelog.d/20240926_151223_dave_private_media.md @@ -0,0 +1 @@ +[Feature] Create a new /data/openedx-media-private volume to store media files that are not publicly accessible via the browser, and create configuration that Learning Core (openedx-learning) will use to access this storage space. Learning Core will use a sub-directory of /data/openedx-media-private to store Content Library file uploads, but other apps can create their own sub-directories for their own use. (by @ormsbee) diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index c317f4c06f..549dd8f74e 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -246,5 +246,14 @@ "user": None, } +LEARNING_CORE = { + 'MEDIA': { + "BACKEND": "django.core.files.storage.FileSystemStorage", + "OPTIONS": { + "location": "/openedx/media-private/openedx-learning", + } + } +} + {{ patch("openedx-common-settings") }} ######## End of settings common to LMS and CMS diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index 63c2d3c7d3..eddc29cb81 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -15,6 +15,7 @@ services: - ../../data/lms:/mounts/lms - ../../data/cms:/mounts/cms - ../../data/openedx-media:/mounts/openedx + - ../../data/openedx-media-private:/mounts/openedx-private {% if RUN_MONGODB %}- ../../data/mongodb:/mounts/mongodb{% endif %} {% if RUN_MYSQL %}- ../../data/mysql:/mounts/mysql{% endif %} {% if RUN_ELASTICSEARCH %}- ../../data/elasticsearch:/mounts/elasticsearch{% endif %} @@ -112,6 +113,7 @@ services: - ../apps/openedx/uwsgi.ini:/openedx/uwsgi.ini:ro - ../../data/lms:/openedx/data - ../../data/openedx-media:/openedx/media + - ../../data/openedx-media-private:/openedx/media-private {%- for mount in iter_mounts(MOUNTS, "openedx", "lms") %} - {{ mount }} {%- endfor %} @@ -138,6 +140,7 @@ services: - ../apps/openedx/uwsgi.ini:/openedx/uwsgi.ini:ro - ../../data/cms:/openedx/data - ../../data/openedx-media:/openedx/media + - ../../data/openedx-media-private:/openedx/media-private {%- for mount in iter_mounts(MOUNTS, "openedx", "cms") %} - {{ mount }} {%- endfor %} @@ -166,6 +169,7 @@ services: - ../apps/openedx/config:/openedx/config:ro - ../../data/lms:/openedx/data - ../../data/openedx-media:/openedx/media + - ../../data/openedx-media-private:/openedx/media-private {%- for mount in iter_mounts(MOUNTS, "openedx", "lms-worker") %} - {{ mount }} {%- endfor %} @@ -185,6 +189,7 @@ services: - ../apps/openedx/config:/openedx/config:ro - ../../data/cms:/openedx/data - ../../data/openedx-media:/openedx/media + - ../../data/openedx-media-private:/openedx/media-private {%- for mount in iter_mounts(MOUNTS, "openedx", "cms-worker") %} - {{ mount }} {%- endfor %} From 717a359dacd74d252417afa4888817511fa7d4ff Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Thu, 26 Sep 2024 16:33:54 -0400 Subject: [PATCH 2/3] temp: change config setting to OPENEDX_LEARNING which better indicates where it's from --- tutor/templates/apps/openedx/settings/partials/common_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index 549dd8f74e..105ac5383c 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -246,7 +246,7 @@ "user": None, } -LEARNING_CORE = { +OPENEDX_LEARNING = { 'MEDIA': { "BACKEND": "django.core.files.storage.FileSystemStorage", "OPTIONS": { From d6dd9cbc06921ff0ea73654a64124dcf1b2329bb Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Wed, 2 Oct 2024 12:49:46 -0400 Subject: [PATCH 3/3] docs: changelog formatting --- changelog.d/20240926_151223_dave_private_media.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/20240926_151223_dave_private_media.md b/changelog.d/20240926_151223_dave_private_media.md index 20354be513..d7d3d16581 100644 --- a/changelog.d/20240926_151223_dave_private_media.md +++ b/changelog.d/20240926_151223_dave_private_media.md @@ -1 +1 @@ -[Feature] Create a new /data/openedx-media-private volume to store media files that are not publicly accessible via the browser, and create configuration that Learning Core (openedx-learning) will use to access this storage space. Learning Core will use a sub-directory of /data/openedx-media-private to store Content Library file uploads, but other apps can create their own sub-directories for their own use. (by @ormsbee) +- [Feature] Create a new /data/openedx-media-private volume to store media files that are not publicly accessible via the browser, and create configuration that Learning Core (openedx-learning) will use to access this storage space. Learning Core will use a sub-directory of /data/openedx-media-private to store Content Library file uploads, but other apps can create their own sub-directories for their own use. (by @ormsbee)