version: '3.8'

services:
  elasticsearch:
    container_name: ${ELASTICSEARCH_CONTAINER_NAME}
    image: elasticsearch:${ES_VERSION}
    environment:
      - discovery.type=single-node
      - ELASTIC_PASSWORD=${ES_PASSWORD}
      #- ES_JAVA_OPTS=${ES_JVM_OPTS}
      - ES_JAVA_OPTS=-Xms2g -Xmx2g
      - xpack.security.enabled=true
      - TZ=Asia/Shanghai
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    ports:
      - "${ES_HTTP_PORT}:9200"
      - "${ES_TRANSPORT_PORT}:9300"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./configs/elasticsearch/hosts:/etc/hosts:ro
      - /etc/timezone:/etc/timezone:ro
      - ./configs/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./data/elasticsearch/data:/usr/share/elasticsearch/data
      - ./data/elasticsearch/logs:/usr/share/elasticsearch/logs
      - ./data/elasticsearch/snapshots:/usr/share/elasticsearch/snapshots
    restart: always

networks:
  default:
    name: ${DEPLOY_ENV}_network
    driver: bridge
