services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:9.0.1
    container_name: elasticsearch
    restart: always
    ports:
      - '9200:9200'
      - '9300:9300'
    networks:
      - nice-net
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=true
      - ELASTIC_PASSWORD=nice_elastic_password
      - 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
    volumes:
      - type: volume
        source: elasticsearch_data
        target: /usr/share/elasticsearch/data
      - type: tmpfs
        target: /tmp
        tmpfs:
          size: 1G
    healthcheck:
      test: curl -s http://localhost:9200/_cluster/health | grep -v '"status":"red"'
      interval: 10s
      timeout: 5s
      retries: 3

volumes:
  elasticsearch_data:
    driver: local
    driver_opts:
      type: none
      device: /opt/projects/nice/volumes/elasticsearch
      o: bind
