Skip to content

Commit

Permalink
feat: add separate bucket for discovery
Browse files Browse the repository at this point in the history
Run init script for minio to create a bucket for discovery
after enabling discovery plugin.
  • Loading branch information
Muhammad Faraz Maqsood authored and Faraz32123 committed Aug 13, 2024
1 parent e3dff55 commit 70b2534
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tutorminio/patches/discovery-common-settings
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tutorminio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}",
Expand Down
11 changes: 11 additions & 0 deletions tutorminio/templates/minio/tasks/minio/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

0 comments on commit 70b2534

Please sign in to comment.