45
DRUPAL 8 + ELASTICSEARCH + DOCKER Roald R. Umandal, Vielsoft Ltd Drupal Camp Manila 2016

Drupal 8 + Elasticsearch + Docker

Embed Size (px)

Citation preview

Page 1: Drupal 8 + Elasticsearch + Docker

DRUPAL 8 + ELASTICSEARCH + DOCKER

Roald R. Umandal, Vielsoft Ltd Co.Drupal Camp Manila 2016

Page 2: Drupal 8 + Elasticsearch + Docker

What we need?• Docker• Docker ubuntu image• Docker elasticsearch image• Apache, MySQL, PHP 5, Drush• Drupal 8

Page 3: Drupal 8 + Elasticsearch + Docker

What is Docker?

Page 4: Drupal 8 + Elasticsearch + Docker

Docker• Docker allows you to package an

application with all of its dependencies into a standardized unit of software development

Page 5: Drupal 8 + Elasticsearch + Docker

Docker• Docker container wrap up a piece of

software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server

Page 6: Drupal 8 + Elasticsearch + Docker

Why Docker• Lightweight• Portable• Isolation• Consistent Environments

Page 7: Drupal 8 + Elasticsearch + Docker

What is Elasticsearch?

Page 8: Drupal 8 + Elasticsearch + Docker

Elasticsearch• Elasticsearch is distributed RESTful

search engine built for the cloud.

Page 9: Drupal 8 + Elasticsearch + Docker

Elasticsearch• Elasticsearch is a search server

based on Lucene. It provides distributed, multitenant-capable full-text search engine with an HTTP web interface and Schema-Free JSON documents.

Page 10: Drupal 8 + Elasticsearch + Docker

Elasticsearch• Elasticsearch is developed in Java

and is released as open source under the terms of the Apache License

Page 11: Drupal 8 + Elasticsearch + Docker

Features• Distributed and Highly Available

Search Engine– Each index is fully sharded with a

configurable number of shards– Each shard can have one or more

replicas– Read/Search operations performed on

any of the replica shards.

Page 12: Drupal 8 + Elasticsearch + Docker

Features• Multi Tenant with Multi Types– Support for more than one index.– Support for more than one type per

index.– Index level configuration (number of

shards, index storage).

Page 13: Drupal 8 + Elasticsearch + Docker

Features• Various set of APIs– HTTP RESTful API– Native Java API– All APIs perform automatic node

operation rerouting

Page 14: Drupal 8 + Elasticsearch + Docker

Features• Document Oriented– No need for upfront schema definition.– Schema can be defined per type for

customization of indexing process.

Page 15: Drupal 8 + Elasticsearch + Docker

Features• Reliable, Asynchronous Write Behind

for long term persistency.• (Near) Real Time Search.• Built on top of lucene– Each shard is fully functional Lucene

index– All the power of Lucene easily exposed

through simple configuration / plugins.

Page 16: Drupal 8 + Elasticsearch + Docker

Features• Per operation consistency– Singe document level operations are

atomic, consistent, isolated and durable.• Open Source under the Apache

License, version 2 (“ALv2”)

Page 17: Drupal 8 + Elasticsearch + Docker

Let’s get started

Page 18: Drupal 8 + Elasticsearch + Docker

Demo

Page 19: Drupal 8 + Elasticsearch + Docker

Setup Drupal 8

docker pull roaldumandal/drupal8 docker run -d -P --name [container name][docker image] docker exec -it [container name | container id]

[command] Start mysql - /etc/init.d/mysql start Start apache - /etc/init.d/apache2 start

Elasticsearch docker pull roaldumandal/elasticsearch docker run -d -P --name [container name][docker image] docker exec -it [container name | container id]

[command] Start elasticsearch - /etc/init.d/elasticsearch start

Page 20: Drupal 8 + Elasticsearch + Docker

Let’s build first our elasticsearch server

Page 21: Drupal 8 + Elasticsearch + Docker

Elasticsearch• docker pull

roaldumandal/elasticsearch

Page 22: Drupal 8 + Elasticsearch + Docker

Elasticsearch• docker run -d -P elasticsearch

roaldumandal/elasticsearch

Page 23: Drupal 8 + Elasticsearch + Docker

Elasticsearch• Login to docker container– docker exec -it elasticsearch bash

Page 24: Drupal 8 + Elasticsearch + Docker

Elasticsearch• Start elasticsearch -

/etc/init.d/elasticsearch start• Type in your terminal exit

Page 25: Drupal 8 + Elasticsearch + Docker

Now where ready to setup our Drupal 8 web server!

Page 26: Drupal 8 + Elasticsearch + Docker

Drupal 8• docker pull roaldumandal/drupal8

Page 27: Drupal 8 + Elasticsearch + Docker

Drupal 8• Create docker your docker container• docker run -d -P --name [container name]

[docker image]• The -d flag keeps the container running in

background after the docker run command completes

• The -p flag publishes exposed ports from the container to your localhost; this lets you access them from your computer

Page 28: Drupal 8 + Elasticsearch + Docker

Drupal 8• docker exec -it [container name | container

id] [command]• After running the command it login you as

root

Page 29: Drupal 8 + Elasticsearch + Docker

Drupal 8• Start mysql - /etc/init.d/mysql start• Start apache - /etc/init.d/apache2

start• Type in on your terminal exit

Page 30: Drupal 8 + Elasticsearch + Docker

Drupal 8• Check newly created container• docker ps -a (This command will list all

available container)

Page 31: Drupal 8 + Elasticsearch + Docker

Drupal 8• Accessing your docker web app in

your computer• Getting your docker default ip run

this command– docker-machine ip default (This will list

your default ip).• Example:– http://192.168.99.100:32773– 32773 is the docker generated port

Page 32: Drupal 8 + Elasticsearch + Docker

Drupal 8• Voila! you already have Drupal 8

running in your local

Page 33: Drupal 8 + Elasticsearch + Docker

Configuring Elasticsearch• Enable elasticsearch connector

Page 34: Drupal 8 + Elasticsearch + Docker

Configuring Elasticsearch• Add cluster name• Set server URL (Elasticsearch server)

Page 35: Drupal 8 + Elasticsearch + Docker

Configuring Elasticsearch • Creating elasticsearch index

Page 36: Drupal 8 + Elasticsearch + Docker

Configuring Elasticsearch• You should be able to see now your

cluster and index

Page 37: Drupal 8 + Elasticsearch + Docker

Configuring Search API• Add search server• Fill up the fields set the elasticsearch

server name• Set the backend type to Elasticsearch

Page 38: Drupal 8 + Elasticsearch + Docker

Configuring Search API• Add search index• Fill up the fields• Set data source to Content:– None except those selected– Bundles: Article

• Server– Elasticsearch Server

• Goto views tab then index the data

Page 39: Drupal 8 + Elasticsearch + Docker

Create views search page• Views module supports elasticsearch

connector module we can build search page using views and set the views settings to index elasticsearch

• Create new view• Name it elasticsearch then save and

edit

Page 40: Drupal 8 + Elasticsearch + Docker

Create views search page• Views Elasticsearch page settings– Format: Unformatted list– Show: Fields– Fields: • Content datasource: Title• Content datasource: Image• Content datasource: Body

• Filter criteria: – Search Fulltext

Page 41: Drupal 8 + Elasticsearch + Docker

Elasticsearch Views

Page 42: Drupal 8 + Elasticsearch + Docker

Questions?

Page 43: Drupal 8 + Elasticsearch + Docker

Thank You

Page 44: Drupal 8 + Elasticsearch + Docker

Need more help?• https://www.docker.com/what-docker• http://www.lucenetutorial.com/basic-concepts.html• https://docs.docker.com/engine/reference/commandline/cli/• https://www.quora.com/What-is-the-difference-between-Doc

ker-and-Vagrant-When-should-you-use-each-one

• http://stackoverflow.com/questions/16647069/should-i-use-vagrant-or-docker-for-creating-an-isolated-environment

• https://medium.com/dev-tricks/apache-and-php-on-docker-44faef716150#.g64yqogkg

• https://docs.docker.com/engine/installation/mac/• https://www.elastic.co/guide/en/elasticsearch/reference/curr

ent/glossary.html

• http://joelabrahamsson.com/elasticsearch-101/• https://www.quora.com/What-are-the-disadvantages-of-usin

g-Elasticsearch-as-a-primary-database

Page 45: Drupal 8 + Elasticsearch + Docker

DisclaimerAll images used in this presentation are borrowed from the internet. Therefore, all rights reserved to the original owner.