Skip to content

Commit

Permalink
Merge branch 'release/7.17.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuflatland-lf committed Mar 5, 2022
2 parents e82fb8d + f1b7338 commit a8719ef
Show file tree
Hide file tree
Showing 10 changed files with 1,303 additions and 932 deletions.
29 changes: 29 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Password for the 'elastic' user (at least 6 characters)
ELASTIC_PASSWORD=

# Password for the 'kibana_system' user (at least 6 characters)
KIBANA_PASSWORD=

# Version of Elastic products
STACK_VERSION=7.17.1

# Set the cluster name
CLUSTER_NAME=LiferayElasticsearchCluster

# Set to 'basic' or 'trial' cdto automatically start the 30-day trial
LICENSE=basic
#LICENSE=trial

# Port to expose Elasticsearch HTTP API to the host
ES_PORT=9200
#ES_PORT=127.0.0.1:9200

# Port to expose Kibana to the host
KIBANA_PORT=5601
#KIBANA_PORT=80

# Increase or decrease based on the available host memory (in bytes)
MEM_LIMIT=1073741824

# Project namespace (defaults to the current folder name if not set)
#COMPOSE_PROJECT_NAME=myproject
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
es/logs
es/data
.env
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: clean
clean: ## Cleanup index
rm -fR ./es/data
mkdir ./es/data

.PHONY: destroy
destroy: ## Destroy all environment including IntelliJ metadata and libraries
docker-compose down --rmi all --volumes --remove-orphans; \
rm -fR ./es/data
rm -fR .gradle
rm -fR .idea

.PHONY: run
run: ## Shorthand of running docker images
docker-compose up --build --remove-orphans

.PHONY: down
down: ## Stop Docker
docker-compose down

.PHONY: help
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# elasticsearch-docker-composer-for-liferay-7

This is for setting up docker-composer to test Elasticsearch and Kuromoji against Liferay 7.3 GA1 / DXP 7.3 SP1 (Elasticsearch 7.9.3).
This is for setting up docker-composer to test Elasticsearch and Kuromoji for Liferay 7.x

## Required environment

- Docker 3.3.3 >=
- Docker 4.5.0 >=
- Java8 or Java11

## How to set up

1. Clone this repository
1. Change the file permission of `/es/docker-entrypoint.sh` to executable.
1. Copy `.env.exampl` and create `.env` in the repository root directory.
1. Go back to the root folder and run `docker-compose up --build` or just `docker-compose up`
1. Start Liferay 7.3
1. Start Liferay 7.x
1. Login as an administrator and navigate to Control Panel -> Configuration -> System Setting -> Search -> Elasticsearch 7
1. Check `Production Mode Enabled` true.
1. Open `index-settings.json` and paste it into `Additional Index Configurations` Text field.
Expand Down
142 changes: 119 additions & 23 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,131 @@
version: "3.8"
services:
setup:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
volumes:
- certs:/usr/share/elasticsearch/config/certs
user: "0"
command: >
bash -c '
if [ x${ELASTIC_PASSWORD} == x ]; then
echo "Set the ELASTIC_PASSWORD environment variable in the .env file";
exit 1;
elif [ x${KIBANA_PASSWORD} == x ]; then
echo "Set the KIBANA_PASSWORD environment variable in the .env file";
exit 1;
fi;
if [ ! -f certs/ca.zip ]; then
echo "Creating CA";
bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip;
unzip config/certs/ca.zip -d config/certs;
fi;
if [ ! -f certs/certs.zip ]; then
echo "Creating certs";
echo -ne \
"instances:\n"\
" - name: elasticsearch\n"\
" dns:\n"\
" - elasticsearch\n"\
" - localhost\n"\
" ip:\n"\
" - 127.0.0.1\n"\
> config/certs/instances.yml;
bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
unzip config/certs/certs.zip -d config/certs;
fi;
echo "Setting file permissions"
chown -R root:root config/certs;
find . -type d -exec chmod 750 \{\} \;;
find . -type f -exec chmod 640 \{\} \;;
echo "Waiting for Elasticsearch availability";
until curl -s --cacert config/certs/ca/ca.crt https://elasticsearch:9200 | grep -q "missing authentication credentials"; do sleep 30; done;
echo "Setting kibana_system password";
until curl -s -X POST --cacert config/certs/ca/ca.crt -u elastic:${ELASTIC_PASSWORD} -H "Content-Type: application/json" https://elasticsearch:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; do sleep 10; done;
echo "All done!";
'
healthcheck:
test: ["CMD-SHELL", "[ -f config/certs/elasticsearch/elasticsearch.crt ]"]
interval: 1s
timeout: 5s
retries: 120

elasticsearch:
build: es
mem_limit: 4g
depends_on:
setup:
condition: service_healthy
build:
context: ./es
args:
- STACK_VERSION=${STACK_VERSION}
volumes:
- certs:/usr/share/elasticsearch/config/certs
- esdata:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
- ${ES_PORT}:9200
environment:
- node.name=elasticsearch
- cluster.name=${CLUSTER_NAME}
- cluster.initial_master_nodes=elasticsearch
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
- bootstrap.memory_lock=true
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=true
- xpack.security.http.ssl.key=certs/elasticsearch/elasticsearch.key
- xpack.security.http.ssl.certificate=certs/elasticsearch/elasticsearch.crt
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
- xpack.security.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.key=certs/elasticsearch/elasticsearch.key
- xpack.security.transport.ssl.certificate=certs/elasticsearch/elasticsearch.crt
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=${LICENSE}
mem_limit: ${MEM_LIMIT}
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./es/data/:/usr/share/elasticsearch/data/
- ./es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- ./es/config/logging.yml:/usr/share/elasticsearch/config/logging.yml
- ./es/config/userdict_ja.txt:/usr/share/elasticsearch/config/userdict_ja.txt
- ./es/logs/:/var/log/elasticsearch/
environment:
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
- discovery.type=single-node
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- xpack.graph.enabled=false
- xpack.ml.enabled=false
- xpack.monitoring.enabled=true
- xpack.watcher.enabled=false
healthcheck:
test:
[
"CMD-SHELL",
"curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'",
]
interval: 10s
timeout: 10s
retries: 120

kibana:
image: docker.elastic.co/kibana/kibana:7.9.3
depends_on:
elasticsearch:
condition: service_healthy
image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
volumes:
- certs:/usr/share/kibana/config/certs
- kibanadata:/usr/share/kibana/data
ports:
- "5601:5601"
- ${KIBANA_PORT}:5601
environment:
- xpack.security.enabled=false
- "ELASTICSEARCH_HOSTS=http://elasticsearch:9200"
- SERVERNAME=kibana
- ELASTICSEARCH_HOSTS=https://elasticsearch:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}
- ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES=config/certs/ca/ca.crt
mem_limit: ${MEM_LIMIT}
healthcheck:
test:
[
"CMD-SHELL",
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'",
]
interval: 10s
timeout: 10s
retries: 120

volumes:
certs:
driver: local
esdata:
driver: local
kibanadata:
driver: local
7 changes: 3 additions & 4 deletions es/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM docker.elastic.co/elasticsearch/elasticsearch:7.9.3
ARG STACK_VERSION=$STACK_VERSION
FROM docker.elastic.co/elasticsearch/elasticsearch:$STACK_VERSION

COPY ./elasticsearch-analysis-kuromoji-ipadic-neologd-7.9.3-SNAPSHOT.zip ./

RUN elasticsearch-plugin install file:./elasticsearch-analysis-kuromoji-ipadic-neologd-7.9.3-SNAPSHOT.zip
RUN elasticsearch-plugin install analysis-kuromoji
RUN elasticsearch-plugin install analysis-icu
RUN elasticsearch-plugin install analysis-smartcn
RUN elasticsearch-plugin install analysis-stempel
5 changes: 4 additions & 1 deletion es/config/userdict_ja.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
東京スカイツリー,東京 スカイツリー,トウキョウ スカイツリー,カスタム名詞
あいうえお,あいうえお,アイウエオ,カスタム名詞
あいうえお,あいうえお,アイウエオ,カスタム名詞
京都府,京都,府,キョウト,フ,カスタム名詞
東京都,東京,都,トウキョウ,ト,カスタム名詞
金メダル,金,メダル,キン,メダル,カスタム名詞
Binary file not shown.
Loading

0 comments on commit a8719ef

Please sign in to comment.