Skip to content

Commit 032e632

Browse files
committed
feat: replace Elasticsearch by Meilisearch
With this change, we get rid of Elasticsearch across all of Tutor. Instead, we run Meilisearch, which is much more lightweight in terms of memory usage. Obviously, this is a (very) breaking change. Indexing commands will be run during init, such that search should work as before. After the edx-search PR is merged and the dependency is upgraded in edx-platform, we should remove the manual `RUN pip install ...` command.
1 parent 2cbe2f2 commit 032e632

31 files changed

+164
-90
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- 💥[Feature] Replace Elasticsearch by Meilisearch. Elasticsearch was both a source of complexity and high resource usage. With this change, we no longer run Elasticsearch to perform common search queries across Open edX. This includes: course discovery, courseware search and studio search. Instead, we index all these documents in a Meilisearch instance, which is much more lightweight in terms of memory consumption. (by @regisb)

docs/configuration.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ With an up-to-date environment, Tutor is ready to launch an Open edX platform an
4040
Individual service activation
4141
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4242

43-
- ``RUN_ELASTICSEARCH`` (default: ``true``)
43+
- ``RUN_MEILISEARCH`` (default: ``true``)
4444
- ``RUN_MONGODB`` (default: ``true``)
4545
- ``RUN_MYSQL`` (default: ``true``)
4646
- ``RUN_REDIS`` (default: ``true``)
@@ -71,9 +71,9 @@ This configuration parameter defines the name of the Docker image to run the dev
7171

7272
This configuration parameter defines which Caddy Docker image to use.
7373

74-
- ``DOCKER_IMAGE_ELASTICSEARCH`` (default: ``"docker.io/elasticsearch:7.17.9"``)
74+
- ``DOCKER_IMAGE_MEILISEARCH`` (default: ``"docker.io/getmeili/meilisearch:v1.8.4"``)
7575

76-
This configuration parameter defines which Elasticsearch Docker image to use.
76+
This configuration parameter defines which Meilisearch Docker image to use.
7777

7878
- ``DOCKER_IMAGE_MONGODB`` (default: ``"docker.io/mongo:7.0.7"``)
7979

@@ -228,13 +228,19 @@ By default, a running Open edX platform deployed with Tutor includes all necessa
228228
.. note::
229229
When configuring an external MySQL database, please make sure it is using version 8.4.
230230

231-
Elasticsearch
232-
*************
231+
Meilisearch
232+
***********
233+
234+
- ``MEILISEARCH_URL`` (default: ``"http://meilisearch:7700"``): internal URL used for backend-to-backend communication.
235+
- ``MEILISEARCH_PUBLIC_URL`` (default: ``"{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://meilisearch.{{ LMS_HOST }}"``): external URL from which the frontend will access the Meilisearch instance.
236+
- ``MEILISEARCH_INDEX_PREFIX`` (default: ``"tutor_"``)
237+
- ``MEILISEARCH_MASTER_KEY`` (default: ``"{{ 24|random_string }}"``)
238+
- ``MEILISEARCH_API_KEY_UID`` (default: ``"{{ 4|uuid }}"``): UID used to sign the API key.
239+
- ``MEILISEARCH_API_KEY`` (default: ``"{{ MEILISEARCH_MASTER_KEY|uid_master_hash(MEILISEARCH_API_KEY_UID) }}"``)
240+
241+
To reset the Meilisearch API key, make sure to unset both the API key and it's UID:
233242

234-
- ``ELASTICSEARCH_SCHEME`` (default: ``"http"``)
235-
- ``ELASTICSEARCH_HOST`` (default: ``"elasticsearch"``)
236-
- ``ELASTICSEARCH_PORT`` (default: ``9200``)
237-
- ``ELASTICSEARCH_HEAP_SIZE`` (default: ``"1g"``)
243+
tutor config save --unset MEILISEARCH_API_KEY_UID MEILISEARCH_API_KEY
238244

239245
MongoDB
240246
*******

docs/tutorials/nightly.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ When running Tutor Nightly, you usually do not want to override your existing Tu
5858
Making changes to Tutor Nightly
5959
-------------------------------
6060

61-
In general pull requests should be open on the "master" branch of Tutor: the "master" branch is automatically merged on the "nightly" branch at every commit, such that changes made to Tutor releases find their way to Tutor Nightly as soon as they are merged. However, sometimes you want to make changes to Tutor Nightly exclusively, and not to the Tutor releases. This might be the case for instance when upgrading the running version of a third-party service (for instance: Elasticsearch, MySQL), or when the master branch requires specific changes. In that case, you should follow the instructions from the :ref:`contributing` section of the docs, with the following differences:
61+
In general pull requests should be open on the "master" branch of Tutor: the "master" branch is automatically merged on the "nightly" branch at every commit, such that changes made to Tutor releases find their way to Tutor Nightly as soon as they are merged. However, sometimes you want to make changes to Tutor Nightly exclusively, and not to the Tutor releases. This might be the case for instance when upgrading the running version of a third-party service (for instance: Meilisearch, MySQL), or when the master branch requires specific changes. In that case, you should follow the instructions from the :ref:`contributing` section of the docs, with the following differences:
6262

6363
- Open your pull request on top of the "nightly" branch instead of "master".
6464
- Add a description of your changes by creating a changelog entry with `make changelog-entry`, as in the master branch.

docs/tutorials/scale.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Offloading data storage
3737

3838
Aside from web workers, the most resource-intensive services are in the data persistence layer. They are, by decreasing resource usage:
3939

40-
- `Elasticsearch <https://www.elastic.co/elasticsearch/>`__: indexing of course contents and forum topics, mostly for search. Elasticsearch is never a source of truth in Open edX, and the data can thus be trashed and re-created safely.
4140
- `MySQL <https://www.mysql.com>`__: structured, consistent data storage which is the default destination of all data.
4241
- `MongoDB <https://www.mongodb.com>`__: structured storage of course data.
4342
- `Redis <https://redis.io/>`__: caching and asynchronous task management.
4443
- `MinIO <https://min.io>`__: S3-like object storage for user-uploaded files, which is enabled by the `tutor-minio <https://github.com/overhangio/tutor-minio>`__ plugin. It is possible to replace MinIO by direct filesystem storage (the default), but scaling will then become much more difficult down the road.
44+
- `Meilisearch <https://www.meilisearch.com>`__: indexing of course contents and forum topics, mostly for search. Meilisearch is never a source of truth in Open edX, and the data can thus be trashed and re-created safely.
4545

4646
When attempting to scale a single-server deployment, we recommend starting by offloading some of these stateful data storage components, in the same order of priority. There are multiple benefits:
4747

tutor/commands/images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _add_images_to_pull(
6363
"""
6464
vendor_images = [
6565
("caddy", "DOCKER_IMAGE_CADDY"),
66-
("elasticsearch", "DOCKER_IMAGE_ELASTICSEARCH"),
66+
("meilisearch", "DOCKER_IMAGE_MEILISEARCH"),
6767
("mongodb", "DOCKER_IMAGE_MONGODB"),
6868
("mysql", "DOCKER_IMAGE_MYSQL"),
6969
("redis", "DOCKER_IMAGE_REDIS"),

tutor/commands/jobs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def _add_core_init_tasks() -> None:
4242
hooks.Filters.CLI_DO_INIT_TASKS.add_item(
4343
("mysql", env.read_core_template_file("jobs", "init", "mysql.sh"))
4444
)
45+
with hooks.Contexts.app("meilisearch").enter():
46+
hooks.Filters.CLI_DO_INIT_TASKS.add_item(
47+
("lms", env.read_core_template_file("jobs", "init", "meilisearch.sh"))
48+
)
4549
with hooks.Contexts.app("lms").enter():
4650
hooks.Filters.CLI_DO_INIT_TASKS.add_item(
4751
(

tutor/commands/k8s.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def _start_base_deployments(_job_name: str, *_args: Any, **_kwargs: Any) -> None
390390
"""
391391
config = tutor_config.load(context.root)
392392
wait_for_deployment_ready(config, "caddy")
393-
for name in ["elasticsearch", "mysql", "mongodb"]:
393+
for name in ["meilisearch", "mysql", "mongodb"]:
394394
if tutor_config.is_service_activated(config, name):
395395
wait_for_deployment_ready(config, name)
396396

tutor/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ def upgrade_obsolete(config: Config) -> None:
235235
for name in [
236236
"ACTIVATE_LMS",
237237
"ACTIVATE_CMS",
238-
"ACTIVATE_ELASTICSEARCH",
239238
"ACTIVATE_MONGODB",
240239
"ACTIVATE_MYSQL",
241240
"ACTIVATE_REDIS",

tutor/env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def _prepare_environment() -> None:
5656
("reverse_host", utils.reverse_host),
5757
("rsa_import_key", utils.rsa_import_key),
5858
("rsa_private_key", utils.rsa_private_key),
59+
("uuid", utils.uuid),
60+
("uid_master_hash", utils.uid_master_hash),
5961
],
6062
)
6163
# Template variables

tutor/plugins/openedx.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
34
import os
45
import re
56
import typing as t
@@ -28,6 +29,17 @@ def _edx_platform_public_hosts(
2829
return hosts
2930

3031

32+
@hooks.Filters.APP_PUBLIC_HOSTS.add()
33+
def _meilisearch_public_hosts(
34+
hosts: list[str], context_name: t.Literal["local", "dev"]
35+
) -> list[str]:
36+
if context_name == "dev":
37+
hosts.append("{{ MEILISEARCH_PUBLIC_URL.split('://')[1] }}:7700")
38+
else:
39+
hosts.append("{{ MEILISEARCH_PUBLIC_URL.split('://')[1] }}")
40+
return hosts
41+
42+
3143
@hooks.Filters.IMAGES_BUILD_MOUNTS.add()
3244
def _mount_edx_platform_build(
3345
volumes: list[tuple[str, str]], path: str

tutor/templates/apps/caddy/Caddyfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,10 @@
8282
}
8383
}
8484

85+
{% if RUN_MEILISEARCH %}
86+
{{ MEILISEARCH_PUBLIC_URL.split("://")[1] }}{$default_site_port} {
87+
import proxy "meilisearch:7700"
88+
}
89+
{% endif %}
90+
8591
{{ patch("caddyfile") }}

tutor/templates/apps/openedx/config/cms.env.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ FEATURES:
99
{{ patch("cms-env-features")|indent(2) }}
1010
CERTIFICATES_HTML_VIEW: true
1111
PREVIEW_LMS_BASE: "{{ PREVIEW_LMS_HOST }}"
12-
ENABLE_COURSEWARE_INDEX: true
1312
ENABLE_CSMH_EXTENDED: false
1413
ENABLE_LEARNER_RECORDS: false
1514
ENABLE_LIBRARY_INDEX: true

tutor/templates/apps/openedx/config/lms.env.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ FEATURES:
99
{{ patch("lms-env-features")|indent(2) }}
1010
CERTIFICATES_HTML_VIEW: true
1111
PREVIEW_LMS_BASE: "{{ PREVIEW_LMS_HOST }}"
12-
ENABLE_COURSE_DISCOVERY: true
13-
ENABLE_COURSEWARE_SEARCH: true
1412
ENABLE_CSMH_EXTENDED: false
15-
ENABLE_DASHBOARD_SEARCH: true
1613
ENABLE_COMBINED_LOGIN_REGISTRATION: true
1714
ENABLE_GRADE_DOWNLOADS: true
1815
ENABLE_LEARNER_RECORDS: false

tutor/templates/apps/openedx/settings/cms/development.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
import os
33
from cms.envs.devstack import *
44

5+
{% include "apps/openedx/settings/partials/common_cms.py" %}
6+
57
LMS_BASE = "{{ LMS_HOST }}:8000"
68
LMS_ROOT_URL = "http://" + LMS_BASE
79

810
CMS_BASE = "{{ CMS_HOST }}:8001"
911
CMS_ROOT_URL = "http://" + CMS_BASE
1012

13+
MEILISEARCH_PUBLIC_URL = "{{ MEILISEARCH_PUBLIC_URL }}:7700"
14+
1115
# Authentication
1216
SOCIAL_AUTH_EDX_OAUTH2_KEY = "{{ CMS_OAUTH2_KEY_SSO_DEV }}"
1317
SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = LMS_ROOT_URL
1418

1519
FEATURES["PREVIEW_LMS_BASE"] = "{{ PREVIEW_LMS_HOST }}:8000"
1620

17-
{% include "apps/openedx/settings/partials/common_cms.py" %}
18-
1921
# Setup correct webpack configuration file for development
2022
WEBPACK_CONFIG_PATH = "webpack.dev.config.js"
2123

tutor/templates/apps/openedx/settings/lms/development.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
CMS_ROOT_URL = "http://{}".format(CMS_BASE)
1616
LOGIN_REDIRECT_WHITELIST.append(CMS_BASE)
1717

18+
MEILISEARCH_PUBLIC_URL = "{{ MEILISEARCH_PUBLIC_URL }}:7700"
19+
1820
# Session cookie
1921
SESSION_COOKIE_DOMAIN = "{{ LMS_HOST }}"
2022
SESSION_COOKIE_SECURE = False

tutor/templates/apps/openedx/settings/partials/common_all.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
# Behave like memcache when it comes to connection errors
3535
DJANGO_REDIS_IGNORE_EXCEPTIONS = True
3636

37-
# Elasticsearch connection parameters
38-
ELASTIC_SEARCH_CONFIG = [{
39-
{% if ELASTICSEARCH_SCHEME == "https" %}"use_ssl": True,{% endif %}
40-
"host": "{{ ELASTICSEARCH_HOST }}",
41-
"port": {{ ELASTICSEARCH_PORT }},
42-
}]
37+
# Meilisearch connection parameters
38+
MEILISEARCH_ENABLED = True
39+
MEILISEARCH_URL = "{{ MEILISEARCH_URL }}"
40+
MEILISEARCH_PUBLIC_URL = "{{ MEILISEARCH_PUBLIC_URL }}"
41+
MEILISEARCH_INDEX_PREFIX = "{{ MEILISEARCH_INDEX_PREFIX }}"
42+
MEILISEARCH_API_KEY = "{{ MEILISEARCH_API_KEY }}"
43+
MEILISEARCH_MASTER_KEY = "{{ MEILISEARCH_MASTER_KEY }}"
44+
SEARCH_ENGINE = "search.meilisearch.MeilisearchEngine"
4345

4446
# Common cache config
4547
CACHES = {

tutor/templates/apps/openedx/settings/partials/common_cms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
FRONTEND_LOGIN_URL = LMS_ROOT_URL + '/login'
2121
FRONTEND_REGISTER_URL = LMS_ROOT_URL + '/register'
2222

23+
# Enable "reindex" button
24+
FEATURES["ENABLE_COURSEWARE_INDEX"] = True
25+
2326
# Create folders if necessary
2427
for folder in [LOG_DIR, MEDIA_ROOT, STATIC_ROOT, ORA2_FILEUPLOAD_ROOT]:
2528
if not os.path.exists(folder):

tutor/templates/apps/openedx/settings/partials/common_lms.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
"LOCATION": "staticfiles_lms",
3838
}
3939

40+
# Enable search features
41+
FEATURES["ENABLE_COURSE_DISCOVERY"] = True
42+
FEATURES["ENABLE_COURSEWARE_SEARCH"] = True
43+
FEATURES["ENABLE_DASHBOARD_SEARCH"] = True
44+
4045
# Create folders if necessary
4146
for folder in [DATA_DIR, LOG_DIR, MEDIA_ROOT, STATIC_ROOT, ORA2_FILEUPLOAD_ROOT]:
4247
if not os.path.exists(folder):

tutor/templates/apps/permissions/setowners.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
setowner $OPENEDX_USER_ID /mounts/lms /mounts/cms /mounts/openedx
3-
{% if RUN_ELASTICSEARCH %}setowner 1000 /mounts/elasticsearch{% endif %}
3+
{% if RUN_MEILISEARCH %}setowner 1000 /mounts/meilisearch{% endif %}
44
{% if RUN_MONGODB %}setowner 999 /mounts/mongodb{% endif %}
55
{% if RUN_MYSQL %}setowner 999 /mounts/mysql{% endif %}
66
{% if RUN_REDIS %}setowner 1000 /mounts/redis{% endif %}

tutor/templates/config/base.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
CMS_OAUTH2_SECRET: "{{ 24|random_string }}"
33
ID: "{{ 24|random_string }}"
44
JWT_RSA_PRIVATE_KEY: "{{ 2048|rsa_private_key }}"
5+
MEILISEARCH_MASTER_KEY: "{{ 24|random_string }}"
6+
MEILISEARCH_API_KEY_UID: "{{ 4|uuid }}"
7+
MEILISEARCH_API_KEY: "{{ MEILISEARCH_MASTER_KEY|uid_master_hash(MEILISEARCH_API_KEY_UID) }}"
58
MYSQL_ROOT_PASSWORD: "{{ 8|random_string }}"
69
OPENEDX_MYSQL_PASSWORD: "{{ 8|random_string }}"
710
OPENEDX_SECRET_KEY: "{{ 24|random_string }}"

tutor/templates/config/defaults.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ DOCKER_IMAGE_OPENEDX: "{{ DOCKER_REGISTRY }}overhangio/openedx:{{ TUTOR_VERSION
1616
DOCKER_IMAGE_OPENEDX_DEV: "openedx-dev:{{ TUTOR_VERSION }}"
1717
# https://hub.docker.com/_/caddy/tags
1818
DOCKER_IMAGE_CADDY: "docker.io/caddy:2.7.4"
19-
# https://hub.docker.com/_/elasticsearch/tags
20-
DOCKER_IMAGE_ELASTICSEARCH: "docker.io/elasticsearch:7.17.13"
19+
# https://hub.docker.com/r/getmeili/meilisearch/tags
20+
DOCKER_IMAGE_MEILISEARCH: "docker.io/getmeili/meilisearch:v1.8.4"
2121
# https://hub.docker.com/_/mongo/tags
2222
DOCKER_IMAGE_MONGODB: "docker.io/mongo:7.0.7"
2323
# https://hub.docker.com/_/mysql/tags
@@ -29,10 +29,6 @@ DOCKER_IMAGE_REDIS: "docker.io/redis:7.2.4"
2929
DOCKER_IMAGE_SMTP: "docker.io/devture/exim-relay:4.96-r1-0"
3030
EDX_PLATFORM_REPOSITORY: "https://github.com/openedx/edx-platform.git"
3131
EDX_PLATFORM_VERSION: "{{ OPENEDX_COMMON_VERSION }}"
32-
ELASTICSEARCH_HOST: "elasticsearch"
33-
ELASTICSEARCH_PORT: 9200
34-
ELASTICSEARCH_SCHEME: "http"
35-
ELASTICSEARCH_HEAP_SIZE: 1g
3632
ENABLE_HTTPS: false
3733
ENABLE_WEB_PROXY: true
3834
JWT_COMMON_AUDIENCE: "openedx"
@@ -42,6 +38,9 @@ K8S_NAMESPACE: "openedx"
4238
LANGUAGE_CODE: "en"
4339
LMS_HOST: "www.myopenedx.com"
4440
LOCAL_PROJECT_NAME: "{{ TUTOR_APP }}_local"
41+
MEILISEARCH_URL: "http://meilisearch:7700"
42+
MEILISEARCH_PUBLIC_URL: "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://meilisearch.{{ LMS_HOST }}"
43+
MEILISEARCH_INDEX_PREFIX: "tutor_"
4544
MONGODB_AUTH_MECHANISM: ""
4645
MONGODB_AUTH_SOURCE: "admin"
4746
MONGODB_HOST: "mongodb"
@@ -73,7 +72,7 @@ REDIS_HOST: "redis"
7372
REDIS_PORT: 6379
7473
REDIS_USERNAME: ""
7574
REDIS_PASSWORD: ""
76-
RUN_ELASTICSEARCH: true
75+
RUN_MEILISEARCH: true
7776
RUN_MONGODB: true
7877
RUN_MYSQL: true
7978
RUN_REDIS: true

tutor/templates/dev/docker-compose.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,20 @@ services:
3232
ports:
3333
- "8001:8000"
3434

35+
{% if RUN_MEILISEARCH -%}
36+
meilisearch:
37+
ports:
38+
- "127.0.0.1:7700:7700"
39+
networks:
40+
default:
41+
aliases:
42+
- "{{ MEILISEARCH_PUBLIC_URL.split('://')[1] }}"
43+
{%- endif %}
44+
3545
# Additional service for watching theme changes
3646
watchthemes:
3747
<<: *openedx-service
3848
command: npm run watch-sass
3949
restart: unless-stopped
4050

41-
{% if RUN_ELASTICSEARCH and is_docker_rootless() %}
42-
elasticsearch:
43-
ulimits:
44-
memlock:
45-
# Fixes error setting rlimits for ready process in rootless docker
46-
soft: 0 # zero means "unset" in the memlock context
47-
hard: 0
48-
{% endif %}
49-
5051
{{ patch("local-docker-compose-dev-services")|indent(2) }}

tutor/templates/jobs/init/cms.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ fi
1616
# Create waffle switches to enable some features, if they have not been explicitly defined before
1717
# Copy-paste of units in Studio (highly requested new feature, but defaults to off in Quince)
1818
(./manage.py cms waffle_flag --list | grep contentstore.enable_copy_paste_units) || ./manage.py lms waffle_flag --create contentstore.enable_copy_paste_units --everyone
19+
20+
# Re-index studio and courseware content
21+
./manage.py cms reindex_studio --experimental
22+
./manage.py cms reindex_course --active

tutor/templates/jobs/init/lms.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ echo "Loading settings $DJANGO_SETTINGS_MODULE"
1010

1111
./manage.py lms migrate
1212

13+
# Create meilisearch indexes
14+
./manage.py lms shell -c "import search.meilisearch; search.meilisearch.create_indexes()"
15+
1316
# Create oauth2 apps for CMS SSO
1417
# https://github.com/openedx/edx-platform/blob/master/docs/guides/studio_oauth.rst
1518
./manage.py lms manage_user cms cms@openedx --unusable-password
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Get or create Meilisearch API key
2+
python -c "
3+
import meilisearch
4+
client = meilisearch.Client('{{ MEILISEARCH_URL }}', '{{ MEILISEARCH_MASTER_KEY }}')
5+
try:
6+
client.get_key('{{ MEILISEARCH_API_KEY_UID }}')
7+
print('Key already exists')
8+
except meilisearch.errors.MeilisearchApiError:
9+
print('Key does not exist: creating...')
10+
client.create_key({
11+
'name': 'Open edX backend API key',
12+
'uid': '{{ MEILISEARCH_API_KEY_UID }}',
13+
'actions': ['*'],
14+
'indexes': ['{{ MEILISEARCH_INDEX_PREFIX }}*'],
15+
'expiresAt': None,
16+
'description': 'Use it for backend API calls -- Created by Tutor',
17+
})
18+
"

0 commit comments

Comments
 (0)