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

Smile Elasticsuite Magento 2 required plugins #3

Open
MisterH001 opened this issue Sep 6, 2022 · 15 comments
Open

Smile Elasticsuite Magento 2 required plugins #3

MisterH001 opened this issue Sep 6, 2022 · 15 comments

Comments

@MisterH001
Copy link

MisterH001 commented Sep 6, 2022

Hello @AronNovak
The Smile ElasticSuite for Magento 2 requires 2 plugins: analysis-phonetic & analysis-icu
This link details what is required: https://github.com/Smile-SA/elasticsuite/wiki/ServerConfig-5.x#installing-required-plugins
It states "Plugins can be installed with the bin/elasticsearch-plugin tool of Elastic Search.":

bin/elasticsearch-plugin install analysis-phonetic
bin/elasticsearch-plugin install analysis-icu

  • How do I use this? (And setup ddev so it installs every time the project is launched?)
    Thank you!
@AronNovak
Copy link
Collaborator

@MisterH001
Your way to go is to create your own Docker image for your needs.
Based on https://github.com/docker-library/elasticsearch/blob/752ea7a8ddcf0a209377f572cfcfdb220bde24ab/7/Dockerfile , you can end up with something like this:

# Elasticsearch 7.17.6

# This image re-bundles the Docker image from the upstream provider, Elastic.
FROM docker.elastic.co/elasticsearch/elasticsearch:7.17.6@sha256:af43249cab60c8069a7868517b5c9d0f6481c6a1ac00e8ec3fa3ae614fb99e63

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu && \ 
    /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-phonetic

Then you can publish it on Dockerhub:
https://docs.docker.com/docker-hub/ - they have a fairly well written guide for that.

After you have your own image, let's say misterh001/elasticsearch, you can add it to your DDEV project by adding such a file:

version: '3.6'
services:
  elasticsearch:
    container_name: ddev-${DDEV_SITENAME}-elasticsearch
    hostname: ${DDEV_SITENAME}-elasticsearch
    image: misterh001/elasticsearch
    expose:
      - "9200"
      - "9300"
    environment:
      - cluster.name=docker-cluster
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - VIRTUAL_HOST=$DDEV_HOSTNAME
      - HTTP_EXPOSE=9200:9200
      - HTTPS_EXPOSE=9201:9200
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    volumes:
      - elasticsearch:/usr/share/elasticsearch/data
      - ".:/mnt/ddev_config"
    healthcheck:
      test: ["CMD-SHELL", "curl --fail -s localhost:9200"]

volumes:
  elasticsearch:

as docker-compose.elasticsearch.yaml

With such a custom image, using ddev-elasticsearch addon would not be needed / possible.

@rfay
Copy link
Member

rfay commented Sep 6, 2022

It's worth having a conversation about whether these should be included by default also, and whether they could be added in the build section of the docker-compose.elasticsearch.yaml.

@MisterH001
Copy link
Author

Thanks @AronNovak @rfay
I have now done this and all working correctly.
Thanks again!

@MisterH001
Copy link
Author

Just further to this, loading from my image now causes Vmmem to run at 100%.
If I swap back to elasticsearch:7.16.2 then it runs fine again

@rfay
Copy link
Member

rfay commented Sep 7, 2022

You may want to find the issue queue for analysis-phonetic and analysis-icu and ask there. You may also need to adjust the memory allocation because of this addition. You see it's set to 512M at https://github.com/drud/ddev-elasticsearch/blob/146664d6454649128b6d66f3e79e67d6bcd4990a/docker-compose.elasticsearch.yaml#L15

You might try it with 1024M, etc.

@cmuench
Copy link

cmuench commented Sep 8, 2022

In our case we use a Dockerfile for that.
We also load the plugins for Magento projects without ElasticSuite. IMHO It does not hurt to load the plugins.

That's how our Dockerfile looks like:

FROM elasticsearch:7.16.1
COPY ./elasticsearch.yaml /usr/share/elasticsearch/config/elasticsearch.yml
WORKDIR /usr/share/elasticsearch

ENV cluster.name=docker-cluster
ENV bootstrap.memory_lock=true
ENV ES_JAVA_OPTS="-Xms512m -Xmx512m"

RUN bin/elasticsearch-plugin install analysis-phonetic
RUN bin/elasticsearch-plugin install analysis-icu

The elasticsearch.yaml settings are not relevant for this issue here.

In this case here we have several options:

  1. We add the plugins always for everyone. I guess there are people with other demands. Then we will have more and more plugins over the time.
  2. We fork the package here. A new "elasticsearch-elasticsuite" package will be published.
  3. We make ddev get more dynamic and allow some kind of configuration. Maybe alreadys possible via ENV vars? // @rfay

@rfay
Copy link
Member

rfay commented Sep 8, 2022

This is easy to do with a build section in the docker-compose.elasticsearch.yaml as well. That would also demonstrate how people can add other things.

@cmuench
Copy link

cmuench commented Sep 8, 2022

This is easy to do with a build section in the docker-compose.elasticsearch.yaml as well. That would also demonstrate how people can add other things.

Yes, that's the way we go.

@rfay
Copy link
Member

rfay commented Sep 8, 2022

@MisterH001 do you want to try the PR? It just consists of adding a build section to the docker-compose and adding the Dockerfile in the install.yaml. You're a good candidate because you're interested and a user.

@jellesiderius
Copy link

Maybe it's a good idea to write this out somewhere in it's full completion. I just cannot seem to get this working with the comments given above.

@PatrickWhitehouse
Copy link

I'm also struggling to get this working on my instance.

@MisterH001
Copy link
Author

Hi @PatrickWhitehouse
In your docker-compose.elasticsearch.yaml file, swap the image from elasticsearch and use my elasticsuite alternative:
image: mrhambley/elasticsearch

Good luck :-)

@jellesiderius
Copy link

jellesiderius commented Sep 12, 2023

Eventually went with this:

version: '3.6'
services:
  elasticsearch:
    container_name: ddev-${DDEV_SITENAME}-elasticsearch
    hostname: ${DDEV_SITENAME}-elasticsearch
    image: elasticsearch:7.17.6
    expose:
      - "9200"
      - "9300"
    environment:
      - cluster.name=docker-cluster
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - VIRTUAL_HOST=$DDEV_HOSTNAME
      - HTTP_EXPOSE=9200:9200
      - HTTPS_EXPOSE=9201:9200
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    command: >
      /bin/sh -c "./bin/elasticsearch-plugin install analysis-phonetic && ./bin/elasticsearch-plugin install analysis-icu; /usr/local/bin/docker-entrypoint.sh"
    volumes:
      - elasticsearch:/usr/share/elasticsearch/data
      - ".:/mnt/ddev_config"
    healthcheck:
      test: ["CMD-SHELL", "curl --fail -s localhost:9200"]

volumes:
  elasticsearch:

@rfay
Copy link
Member

rfay commented Sep 12, 2023

Thanks for sharing!

You could also have done this with a .ddev/docker-compose.elasticsearch-extra.yaml with just overrode the command.

But if you're doing this, remove the #ddev-generated do that it doesn't get overwritten by ddev get.

A nit: the version is no longer used in docker-compose.

@ProxiBlue
Copy link

I prefer to keep the service yaml files intact, so it also works if you add a custom .yaml and then add the needed changes there.
IMO, this keeps the plugin files intact allowing for updates (if needed)

services:
  elasticsearch:
    command: >
      /bin/sh -c "./bin/elasticsearch-plugin install analysis-phonetic && ./bin/elasticsearch-plugin install analysis-icu; /usr/local/bin/docker-entrypoint.sh"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants