Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to disable and configure meilisearch host #6

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tutor_meili/patches/caddyfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% if MEILISEARCH_RUN %}
# Meilisearch
{{ MEILISEARCH_PUBLIC_HOST }}{$default_site_port} {
import proxy "meilisearch:7700"
import proxy "{{MEILISEARCH_HOST}}"
}
{% endif %}
2 changes: 2 additions & 0 deletions tutor_meili/patches/k8s-deployments
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if MEILISEARCH_RUN %}
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -31,3 +32,4 @@ spec:
- name: data
persistentVolumeClaim:
claimName: meilisearch
{% endif %}
2 changes: 2 additions & 0 deletions tutor_meili/patches/k8s-services
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if MEILISEARCH_RUN %}
---
apiVersion: v1
kind: Service
Expand All @@ -11,3 +12,4 @@ spec:
name: meilisearch
selector:
app.kubernetes.io/name: meilisearch
{% endif %}
2 changes: 2 additions & 0 deletions tutor_meili/patches/k8s-volumes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if MEILISEARCH_RUN %}
---
apiVersion: v1
kind: PersistentVolumeClaim
Expand All @@ -12,3 +13,4 @@ spec:
resources:
requests:
storage: 5Gi
{% endif %}
2 changes: 2 additions & 0 deletions tutor_meili/patches/local-docker-compose-caddy-aliases
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{% if MEILISEARCH_RUN %}
- "{{ MEILISEARCH_PUBLIC_HOST }}"
{% endif %}
2 changes: 2 additions & 0 deletions tutor_meili/patches/local-docker-compose-dev-services
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% if MEILISEARCH_RUN %}
meilisearch:
ports:
- "127.0.0.1:7700:7700"
networks:
default:
aliases:
- "{{ MEILISEARCH_PUBLIC_HOST }}"
{% endif %}
2 changes: 2 additions & 0 deletions tutor_meili/patches/local-docker-compose-services
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Meilisearch
{% if MEILISEARCH_RUN %}
meilisearch:
image: {{ MEILISEARCH_DOCKER_IMAGE }}
volumes:
- ../../data/meilisearch:/meili_data
environment:
MEILI_MASTER_KEY: "{{ MEILISEARCH_MASTER_KEY }}"
restart: unless-stopped
{% endif %}
2 changes: 1 addition & 1 deletion tutor_meili/patches/openedx-cms-production-settings
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MEILISEARCH_URL = "http://meilisearch:7700"
MEILISEARCH_URL = "http://{{ MEILISEARCH_HOST }}"
MEILISEARCH_PUBLIC_URL = "https://{{ MEILISEARCH_PUBLIC_HOST }}"
2 changes: 1 addition & 1 deletion tutor_meili/patches/openedx-development-settings
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MEILISEARCH_URL = "http://meilisearch:7700"
MEILISEARCH_URL = "http://{{ MEILISEARCH_HOST }}"
MEILISEARCH_PUBLIC_URL = "http://{{ MEILISEARCH_PUBLIC_HOST }}:7700"
6 changes: 4 additions & 2 deletions tutor_meili/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
"defaults": {
"VERSION": __version__,
# use an index prefix to segregate data if you have multiple Open edX instances sharing one Meilisearch instance
"INDEX_PREFIX": "tutor_",
"INDEX_PREFIX": "openedx_{{K8S_NAMESPACE}}_",
"PUBLIC_HOST": "meilisearch.{{ LMS_HOST }}",
"DOCKER_IMAGE": "docker.io/getmeili/meilisearch:v1.8",
"RUN": False,
"HOST": "meilisearch:7700",
},
"unique": {
# A key that we use during init to generate an API key, if required
Expand All @@ -51,7 +53,7 @@

# Add configuration entries
tutor_hooks.Filters.CONFIG_DEFAULTS.add_items(
[(f"MEILISEARCH_{key}", value) for key, value in config.get("defaults", {}).items()]
[(f"MEILISEARCH_{key}", value) for key, value in config.get("defaults", {}).items()] + []
)
tutor_hooks.Filters.CONFIG_UNIQUE.add_items(
[(f"MEILISEARCH_{key}", value) for key, value in config.get("unique", {}).items()]
Expand Down
4 changes: 2 additions & 2 deletions tutor_meili/templates/meilisearch/tasks/meilisearch/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Create the API key using the master key.
# The result is actually deterministic:
# https://www.meilisearch.com/docs/learn/security/master_api_keys#using-the-master-key-to-manage-api-keys
curl -X GET -H 'Authorization: Bearer {{ MEILISEARCH_MASTER_KEY }}' 'http://meilisearch:7700/keys/{{ MEILISEARCH__INTERNAL_API_KEY_UID }}' | grep api_key_not_found && curl \
-X POST 'http://meilisearch:7700/keys' \
curl -X GET -H 'Authorization: Bearer {{ MEILISEARCH_MASTER_KEY }}' 'http://{{ MEILISEARCH_HOST }}/keys/{{ MEILISEARCH__INTERNAL_API_KEY_UID }}' | grep api_key_not_found && curl \
-X POST 'http://{{ MEILISEARCH_HOST }}/keys' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{ MEILISEARCH_MASTER_KEY }}' \
--data-binary '{
Expand Down