Open MisterH001 opened 2 years ago
@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.
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.
Thanks @AronNovak @rfay I have now done this and all working correctly. Thanks again!
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
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.
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:
ddev get
more dynamic and allow some kind of configuration. Maybe alreadys possible via ENV vars? // @rfay 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.
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.
@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.
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.
I'm also struggling to get this working on my instance.
Hi @PatrickWhitehouse In your docker-compose.elasticsearch.yaml file, swap the image from elasticsearch and use my elasticsuite alternative: image: mrhambley/elasticsearch
Good luck :-)
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:
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.
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"
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