112 lines
3.5 KiB
YAML
112 lines
3.5 KiB
YAML
version: "3.9"
|
|
|
|
# hint: run the following if the container fails to start locally
|
|
# sysctl -w vm.max_map_count=262144
|
|
services:
|
|
setup:
|
|
image: public.ecr.aws/elastic/elasticsearch:${ELASTIC_TAG}
|
|
volumes:
|
|
- ./elastic:/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;
|
|
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://es01: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://es01: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/ca/ca.crt ]"]
|
|
interval: 1s
|
|
timeout: 5s
|
|
retries: 120
|
|
|
|
es01:
|
|
depends_on:
|
|
setup:
|
|
condition: service_healthy
|
|
image: public.ecr.aws/elastic/elasticsearch:${ELASTIC_TAG}
|
|
container_name: elasticsearch
|
|
hostname: elasticsearch
|
|
volumes:
|
|
- ./elastic:/usr/share/elasticsearch/config/certs
|
|
- esdata01:/usr/share/elasticsearch/data
|
|
ports:
|
|
- 9200:9200
|
|
environment:
|
|
- node.name=es01
|
|
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
|
|
- bootstrap.memory_lock=true
|
|
- discovery.type=single-node
|
|
- xpack.security.enabled=true
|
|
- xpack.security.http.ssl.enabled=true
|
|
- xpack.security.http.ssl.key=certs/es01/es01.key
|
|
- xpack.security.http.ssl.certificate=certs/es01/es01.crt
|
|
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
|
|
- xpack.license.self_generated.type=${LICENSE}
|
|
mem_limit: 4G
|
|
ulimits:
|
|
memlock:
|
|
soft: -1
|
|
hard: -1
|
|
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
|
|
restart: always
|
|
networks:
|
|
- emqx_bridge
|
|
|
|
kibana:
|
|
depends_on:
|
|
es01:
|
|
condition: service_healthy
|
|
image: public.ecr.aws/elastic/kibana:${ELASTIC_TAG}
|
|
volumes:
|
|
- ./elastic:/usr/share/kibana/config/certs
|
|
- kibanadata:/usr/share/kibana/data
|
|
ports:
|
|
- 5601:5601
|
|
environment:
|
|
- SERVERNAME=kibana
|
|
- ELASTICSEARCH_HOSTS=https://es01:9200
|
|
- ELASTICSEARCH_USERNAME=kibana_system
|
|
- ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}
|
|
- ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES=config/certs/ca/ca.crt
|
|
mem_limit: 1073741824
|
|
healthcheck:
|
|
test:
|
|
[
|
|
"CMD-SHELL",
|
|
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'",
|
|
]
|
|
interval: 10s
|
|
timeout: 10s
|
|
retries: 120
|
|
restart: always
|
|
networks:
|
|
- emqx_bridge
|
|
|
|
volumes:
|
|
esdata01:
|
|
driver: local
|
|
kibanadata:
|
|
driver: local
|