From 8d2c8e78dc14de85a72e197955097ccc878a6aa4 Mon Sep 17 00:00:00 2001 From: Alban Jubert Date: Thu, 4 Jul 2019 16:23:48 +0200 Subject: [PATCH] Updates Elasticsearch quick start by adding DDEV Added instructions and services files for Elasticsearch DDEV services. --- elasticsearch-quickstart.md | 17 +++++-- .../ddev/docker-compose.elasticsearch.yaml | 51 +++++++++++++++++++ resources/ddev/elasticsearch-build/Dockerfile | 3 ++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 resources/ddev/docker-compose.elasticsearch.yaml create mode 100644 resources/ddev/elasticsearch-build/Dockerfile diff --git a/elasticsearch-quickstart.md b/elasticsearch-quickstart.md index 334e29b..9046597 100644 --- a/elasticsearch-quickstart.md +++ b/elasticsearch-quickstart.md @@ -5,13 +5,24 @@ The craft-elasticsearch plugin isn't very useless without an Elasticsearch serve In this guide we'll walk you through the steps to set up both a development and a production Elasticsearch instance. +## Development using DDEV -## Development +A super easy way to get up and running is by using [DDEV][ddev]. + +Once the initial configuration is done, simply copy the content of `vendor/la-haute-societe/craft-elasticsearch/resources/ddev` into your `.ddev` project folder +then start or restart your DDEV environment. + +This will start an Elasticsearch and Kibana services, respectively accessible at and . + +From the Elasticsearch plugin setting, you use to point to the Elasticsearch instance. + + +## Development using a Docker container To have a development environment up & running in minutes, use Docker: ```sh -cd /resources/docker +cd vendor/la-haute-societe/craft-elasticsearch/resources/docker docker-compose up ``` @@ -27,10 +38,10 @@ to your docker-compose php container definition so it points your apache host to For example, if your Craft CMS instance is accessible through `http://docker.test`, you will define an extra_hosts entry as follow: `- "docker.test:xxx.xxx.xxx.xxx"` where xxx.xxx.xxx.xxx represent your public IP. - ## Production If you need a hassle-free, secure, scalable & production-ready solution, [Elastic Cloud][elasticsearch-cloud] is the way to go. [elasticsearch-cloud]: https://www.elastic.co/cloud/elasticsearch-service +[ddev]: https://ddev.readthedocs.io/en/stable/ diff --git a/resources/ddev/docker-compose.elasticsearch.yaml b/resources/ddev/docker-compose.elasticsearch.yaml new file mode 100644 index 0000000..9da8fa1 --- /dev/null +++ b/resources/ddev/docker-compose.elasticsearch.yaml @@ -0,0 +1,51 @@ +version: '3.6' + +services: + + elasticsearch: + build: ./elasticsearch-build + container_name: ddev-${DDEV_SITENAME}-elasticsearch + environment: + - cluster.name=yii2-test-cluster + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - ELASTIC_PASSWORD=9kMf8NWZRXxV + - VIRTUAL_HOST=$DDEV_HOSTNAME # This defines the host name the service should be accessible from. This will be sitename.ddev.local + - HTTP_EXPOSE=9200 + ulimits: + memlock: + soft: -1 + hard: -1 + restart: on-failure + volumes: + - es6-data:/usr/share/elasticsearch/data + ports: + - 9200 + labels: + com.ddev.site-name: ${DDEV_SITENAME} + com.ddev.approot: $DDEV_APPROOT + com.ddev.app-url: $DDEV_URL + + + kibana: + image: docker.elastic.co/kibana/kibana:6.1.4 + container_name: ddev-${DDEV_SITENAME}-kibana + environment: + - elasticsearch.password=9kMf8NWZRXxV + - VIRTUAL_HOST=$DDEV_HOSTNAME # This defines the host name the service should be accessible from. This will be sitename.ddev.local + - HTTP_EXPOSE=5601 + ports: + - 5601 + labels: + com.ddev.site-name: ${DDEV_SITENAME} + com.ddev.approot: $DDEV_APPROOT + com.ddev.app-url: $DDEV_URL + + web: + links: + - elasticsearch:$DDEV_HOSTNAME + - kibana:$DDEV_HOSTNAME + +volumes: + es6-data: + driver: local diff --git a/resources/ddev/elasticsearch-build/Dockerfile b/resources/ddev/elasticsearch-build/Dockerfile new file mode 100644 index 0000000..ea1a5ef --- /dev/null +++ b/resources/ddev/elasticsearch-build/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.elastic.co/elasticsearch/elasticsearch:6.1.4 + +RUN printf "y/n" | bin/elasticsearch-plugin install ingest-attachment