version: '3'
services:
  opensearch-node1: # This is also the hostname of the container within the Docker network (i.e. http://opensearch-node1/)
    image: opensearchproject/opensearch:2.10.0
    container_name: opensearch-node1
    environment:
      - node.name=opensearch-node1 # Name the node that will run in this container
      - plugins.security.disabled=true # security has been disabled, so no login or password is required.
      - discovery.type=single-node
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
    volumes:
      - opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
    ports:
      - 9200:9200 # REST API
      - 9600:9600 # Performance Analyzer
    networks:
      - opensearch-net # All of the containers will join the same Docker bridge network

# opensearch-dashboards does not work if OpenSearch cluster is not secure.
# to use dashboards, build opensearch-dashboards-no-security first by running
# 
  opensearch-dashboards:
    image: opensearch-dashboards-no-security
    container_name: opensearch-dashboards
    ports:
      - 5601:5601 # Map host port 5601 to container port 5601
    expose:
      - "5601" # Expose port 5601 for web access to OpenSearch Dashboards
    environment:
      OPENSEARCH_HOSTS: '["http://opensearch-node1:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query
    networks:
      - opensearch-net

volumes:
  opensearch-data1:

networks:
  opensearch-net:
  