From edf026ff37cae62c2760b073146f58a1674aed6c Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 13 Aug 2024 17:50:37 +0500 Subject: [PATCH 1/2] feat: add separate bucket for discovery Run init script for minio to create a bucket for discovery after enabling discovery plugin. --- tutorminio/patches/discovery-common-settings | 10 ++++++++++ tutorminio/plugin.py | 1 + tutorminio/templates/minio/tasks/minio/init.sh | 11 +++++++++++ 3 files changed, 22 insertions(+) create mode 100644 tutorminio/patches/discovery-common-settings diff --git a/tutorminio/patches/discovery-common-settings b/tutorminio/patches/discovery-common-settings new file mode 100644 index 0000000..24bb114 --- /dev/null +++ b/tutorminio/patches/discovery-common-settings @@ -0,0 +1,10 @@ +# MinIO object storage +DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" +AWS_ACCESS_KEY_ID = "{{ OPENEDX_AWS_ACCESS_KEY }}" +AWS_SECRET_ACCESS_KEY = "{{ OPENEDX_AWS_SECRET_ACCESS_KEY }}" +AWS_S3_SIGNATURE_VERSION = "s3v4" +AWS_S3_ENDPOINT_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MINIO_HOST }}" +AWS_STORAGE_BUCKET_NAME = "discoveryuploads" +AWS_S3_CUSTOM_DOMAIN = "{{ MINIO_HOST }}/discoveryuploads" +AWS_S3_URL_PROTOCOL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}:" +AWS_QUERYSTRING_EXPIRE = 7 * 24 * 60 * 60 # 1 week: this is necessary to generate valid download urls diff --git a/tutorminio/plugin.py b/tutorminio/plugin.py index 710e145..6225ea5 100644 --- a/tutorminio/plugin.py +++ b/tutorminio/plugin.py @@ -34,6 +34,7 @@ "DOCKER_IMAGE": "docker.io/minio/minio:RELEASE.2022-03-26T06-49-28Z.hotfix.26ec6a857", "MC_DOCKER_IMAGE": "docker.io/minio/mc:RELEASE.2022-03-31T04-55-30Z", "GATEWAY": None, + "DISCOVERY_BUCKET_NAME": "{% if 'discovery' in PLUGINS %}discoveryuploads{% endif %}", }, "unique": { "AWS_SECRET_ACCESS_KEY": "{{ 24|random_string }}", diff --git a/tutorminio/templates/minio/tasks/minio/init.sh b/tutorminio/templates/minio/tasks/minio/init.sh index 628b480..2ccff20 100644 --- a/tutorminio/templates/minio/tasks/minio/init.sh +++ b/tutorminio/templates/minio/tasks/minio/init.sh @@ -7,3 +7,14 @@ mc policy set public minio/{{ MINIO_BUCKET_NAME }} {% else %} echo "⚠️ It is your responsibility to grant public read access rights to the '{{ MINIO_BUCKET_NAME }}' bucket on Azure." {% endif %} + +# discovery bucket +{% if MINIO_DISCOVERY_BUCKET_NAME %} +mc mb --ignore-existing minio/{{ MINIO_DISCOVERY_BUCKET_NAME }} +{% if MINIO_GATEWAY != "azure" %} +# Make discovery media upload bucket public +mc policy set public minio/{{ MINIO_DISCOVERY_BUCKET_NAME }} +{% else %} +echo "⚠️ It is your responsibility to grant public read access rights to the '{{ MINIO_DISCOVERY_BUCKET_NAME }}' bucket on Azure." +{% endif %} +{% endif %} From 40ef14099af420b1fbc7b19cc67b40b796e432f2 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 13 Aug 2024 17:51:09 +0500 Subject: [PATCH 2/2] doc: add changelog entry --- ...702_152230_faraz.maqsood_add_separate_bucket_for_discovery.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/20240702_152230_faraz.maqsood_add_separate_bucket_for_discovery.md diff --git a/changelog.d/20240702_152230_faraz.maqsood_add_separate_bucket_for_discovery.md b/changelog.d/20240702_152230_faraz.maqsood_add_separate_bucket_for_discovery.md new file mode 100644 index 0000000..d2df59e --- /dev/null +++ b/changelog.d/20240702_152230_faraz.maqsood_add_separate_bucket_for_discovery.md @@ -0,0 +1 @@ +- [Feature] Add support for discovery media files in minio and a separate bucket for discovery in Minio. (by @Faraz32123)