Skip to content

Instantly share code, notes, and snippets.

@pinkeen
Last active June 10, 2019 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinkeen/7da03e52b4805b4a8d54f637693bac8f to your computer and use it in GitHub Desktop.
Save pinkeen/7da03e52b4805b4a8d54f637693bac8f to your computer and use it in GitHub Desktop.
Add Elasticsearch plugins to Magento Cloud docker container when running locally
version: '2'
services:
elasticsearch:
image: you-can-use-some-local-image-name/magento-cloud-elasticsearch-with-plugins
build:
context: docker/elasticsearch-dev/
FROM magento/magento-cloud-docker-elasticsearch:6.5
# Elasticsearch with custom plugins for local setup /FS
RUN bin/elasticsearch-plugin install analysis-icu && \
bin/elasticsearch-plugin install analysis-phonetic

How to add Elasticsearch plugins to Magento Cloud local docker setup

Please see the Official Magento Cloud docs first.

This guide has been created because the environment service configuration setting for this does not work with local docker container setup.

  1. Install the project's composer dependencies

    This is needed so the docker directory is created and ece-tools installed.

    composer install --ignore-platform-reqs
    

    You local machine probably doesn't have all the required PHP extensions hence the --ignore-platform-reqs switch.

    Usually this switch may cause problems if it was a real build, because different vendor version could be installed. In this case it will be fine because the real build process is completely isolated in a docker container.

  2. Set up Magento Cloud docker environement according to the documentation.

  3. Create the directory docker/elasticsearch-dev.

  4. Save the contents of attached elasticsearch-dev.Dockerfile to docker/elasticsearch-dev/Dockerfile.

  5. Customize the new docker file.

    • Set the elasticsearch version you need - it should be one of the available tags.
    • Customize the plugins to be installed.
  6. As mentioned in the original documentation extend the docker-compose setup with custom modifications - save the contents of docker-compose-dev.yml to the same filename in your main project directory.

  7. From now on instead of running docker-compose run {parameters} you will have to enter:

    docker-compose -f docker-compose.yml -f docker-compose-dev.yml run {parameters}
    

Note: When you change the custom elasticsearch file after the container has been built docker-compose will not automatically rebuild the container - you need to run docker-compose -f docker-compose.yml -f docker-compose-dev.yml build to force it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment