captainVersion: 4
services:
    $$cap_appname-mongodb:
        image: mongo:$$cap_mongo_version
        volumes:
            - $$cap_appname-db-data:/data/db
            - $$cap_appname-db-config:/data/configdb
        restart: always
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:$$cap_elasticsearch_version
        volumes:
            - $$cap_appname-elasticsearch-data:/usr/share/elasticsearch/data
        restart: always
        environment:
            ES_JAVA_OPTS: -Xms512m -Xmx512m
            cluster.name: $$cap_elasticsearch_cluster_name
            http.port: $$cap_container_port
            node.master: $$cap_elasticsearch_node_master
            node.data: $$cap_elasticsearch_node_data
            discovery.zen.minimum_master_nodes: $$cap_elasticsearch_minimum_master_nodes
            discovery.zen.ping.unicast.hosts: $$cap_elasticsearch_unicast_hosts
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname:
        depends_on:
            - $$cap_appname-mongodb
            - $$cap_appname-elasticsearch
        image: graylog/graylog:$$cap_graylog_version
        restart: always
        environment:
            GRAYLOG_MONGODB_URI: mongodb://srv-captain--$$cap_appname-mongodb/graylog
            GRAYLOG_ELASTICSEARCH_HOSTS: http://srv-captain--$$cap_appname-elasticsearch:$$cap_container_port
            GRAYLOG_HTTP_EXTERNAL_URI: //$$cap_appname.$$cap_root_domain/
            GRAYLOG_ROOT_PASSWORD_SHA2: $$cap_graylog_password
        caproverExtra:
            containerHttpPort: '9000'
caproverOneClickApp:
    variables:
        - id: $$cap_graylog_version
          label: Graylog Version
          defaultValue: '3.1'
          description: Checkout their docker page for the valid tags https://hub.docker.com/r/graylog/graylog/tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_graylog_password
          label: Graylog Admin Password
          defaultValue: ''
          description: 'Admin password SHA256 encoded. Generate with: echo -n "<password>" | shasum -a 256 | cut -d" " -f1'
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_mongo_version
          label: MongoDB Version
          defaultValue: '4'
          description: Checkout their docker page for the valid tags https://hub.docker.com/r/library/mongo/tags/
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_elasticsearch_version
          label: 'Elasticsearch Version Tag '
          description: 'Checkout the releases overview: https://www.elastic.co/de/downloads/elasticsearch'
          defaultValue: 6.7.1
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_elasticsearch_cluster_name
          label: Elasticsearch Cluster Name
          description: Only nodes within the same cluster name can be combined
          defaultValue: elasticsearch-cluster
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_elasticsearch_unicast_hosts
          label: Elasticsearch Unicasts hosts
          description: 'References to other node to attach to. (for example: srv-captain--XXX)'
          defaultValue: 'false'
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_elasticsearch_node_data
          label: Elasticsearch Node Data
          description: Should the node used for storing data? (true / false)
          defaultValue: 'true'
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_elasticsearch_node_master
          label: Elasticsearch Node Master
          description: Define node as master-eligible (usual first node YES, others NO).
          defaultValue: 'true'
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_elasticsearch_minimum_master_nodes
          label: Elasticsearch Minimum Master Nodes
          description: 'Define minimum amount of master (N) ( best practice: ceil(N/2 + 1) ).'
          defaultValue: '1'
          validRegex: /^([0-9])+$/
        - id: $$cap_container_port
          label: Elasticsearch Container TCP Port
          defaultValue: '9200'
          description: Internal port for Elasticsearch the container listens to.
          validRegex: /^([0-9])+$/
    instructions:
        start: >-
            Graylog Log Management. 


            NOTICE!:
             Be sure to extend the virtual memory on all your hosts! 
              1. echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
              2. sysctl -p
        end: >-
            Deployment of Graylog if finished. 
            You will see 502 errors for the next 5+ minutes while Graylog starts up. 
            Goto <YOUR-APP-URL> and login as "admin" with your unhashed password.

            IMPORTANT! Do not forget to map port 12201 and 12202 in your app config. Without port mapping, Graylog will not work.

    displayName: ''
    isOfficial: true
    description: Graylog is used for log management of both structured and unstructured data along with debugging applications.
    documentation: Taken from https://hub.docker.com/r/graylog/graylog
