version: '2.2'
services:
  es01:
    image: ${elasticImage-registry.int.sup.sdzecom.de/umarex/elasticsearch:CS21.6}
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=ExportCluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms${elasticXms-8192m} -Xmx${elasticXmx-8192m}"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es_data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - internal
  es02:
    image: ${elasticImage-registry.int.sup.sdzecom.de/umarex/elasticsearch:CS21.6}
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=ExportCluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms2048m -Xmx2048m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es_data02:/usr/share/elasticsearch/data
    networks:
      - internal
  es03:
    image: ${elasticImage-registry.int.sup.sdzecom.de/umarex/elasticsearch:CS21.6}
    container_name: es03
    environment:
      - node.name=es03
      - cluster.name=ExportCluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms2048m -Xmx2048m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es_data03:/usr/share/elasticsearch/data
    networks:
      - internal

  cassandra:
    environment:
      - "JVM_OPTS=-Xms${cassandraXms-8192m} -Xmx${cassandraXmx-8192m}"
    labels:
      "traefik.enable": "false"
    image: ${cassandraImage-registry.int.sup.sdzecom.de/runtime/production-cassandra:cs21.4.1}
    tty: true
    restart: "always"
    ports:
      - "9042:9042"
    volumes:
      - "cas_data01:/var/lib/cassandra"
      - "cas_logs01:/var/log/cassandra"
    networks:
      - internal

  activemq:
    environment:
      - "ACTIVEMQ_OPTS_MEMORY=-Xms${activemqXms-1024m} -Xmx${activemqXmx-1024m}"
    labels:
      "traefik.enable": "false"
    image: ${activemqImage-registry.int.sup.sdzecom.de/runtime/production-activemq:cs21.4.1}
    tty: true
    restart: "always"
    ports:
      - "8161:8161"
      - "1883:1883"
      - "5672:5672"
      - "61613:61613"
      - "61614:61614"
      - "61616:61616"
    volumes:
      - "/daten/activemq-data:/opt/activemq/data"
    networks:
      - internal

  mariadb:
    environment:
      zabbixServer: ${zabbixServerIP-0.0.0.0}
      enableZabbixMonitoring: ${enableMonitoring-no}
      innodb_read_io_threads: ${innodb_read_io_threads-4}
      innodb_write_io_threads: ${innodb_write_io_threads-8}
      innodb_buffer_pool_size: ${innodb_buffer_pool_size-8192M}
      MARIADB_DATABASE: ${databaseName-production}
      MARIADB_USER: ${databaseUsername-contentserv}
      MARIADB_PASSWORD: ${databasePassword-root}
      MARIADB_ROOT_PASSWORD: ${databaseRootPassword-root123456}
    labels:
      "traefik.enable": "false"
    image: ${mariadbImage-registry.int.sup.sdzecom.de/runtime/production-mariadb:cs21.4.1}
    tty: true
    restart: "always"
    ports:
      - "3306:3306"
    volumes:
      - "mariadb-data:/var/lib/mysql"
      - "mariadb-logs:/var/log/mysql"
    networks:
      - internal

  web:
    privileged: true
    environment:
      zabbixServer: ${zabbixServerIP-0.0.0.0}
      enableZabbixMonitoring: ${enableMonitoring-no}
      projectName: ${projectName}
      enableExportExecutor: ${autostartExportExecutor-yes}
      enablePdfReactor: ${enablePdfReactor-no}
      authInfo: ${authinfo-}
      ESmemory: ${ESmemory-8192M}
      php_memory_limit: ${php_memory_limit-2048M}
      cassandra_container_name: cassandra
      databaseHost: mariadb
      databaseName: ${databaseName-production}
      databaseTablePrefix: ${databaseTablePrefix-cs}
      databaseUser: ${databaseUsername-contentserv}
      databasePassword: ${databasePasswordBase64}
      webserverExternalBasePath: ${webserverExternalBasePath-/}
      webserverExternalPort: ${webserverExternalPort-443}
      webserverExternalProtocol: ${webserverExternalProtocol-https}
      webserverExternalServerName: ${webserverExternalServerName}
      webserverInternalBasePath: ${webserverInternalBasePath-/}
      webserverInternalPort: ${webserverInternalPort-80}
      webserverInternalProtocol: ${webserverInternalProtocol-http}
      webserverInternalServerName: ${webserverInternalServerName-localhost}
      webserverInternalWebserverPassword: ${webserverInternalWebserverPassword-}
      webserverInternalWebserverUser: ${webserverInternalWebserverUser-}
      coreCSLicenseRecordID: ${coreCSLicenseRecordID-}
      coreCSNetUser: ${coreCSNetUser-}
      coreLicenseKey: ${coreLicenseKey-}
      coreOrderedLicenseID: ${coreOrderedLicenseID-}
      coreAlternativeServerName: ${coreAlternativeServerNames-}
      coreEULA: ${coreEULA-}
      coreServerName: ${coreServerName-}
      coreServerPath: ${coreServerPath-}
      coreServerType: ${coreServerType-}
      coreLic5: ${coreLic5-}
    labels:
      "traefik.enable": "true"
      "traefik.docker.network": "${traefikNetwork}"
      "traefik.http.services.cs21web.loadbalancer.server.port": "80"
      "traefik.http.routers.cs21web.tls": "trls -laue"
      "traefik.http.routers.cs21web.rule": "Host(`${webserverExternalServerName}`)"
      "traefik.http.routers.cs21web.entrypoints": "websecure"
    image: ${webImage-registry.int.sup.sdzecom.de/runtime/production-web:cs21.4.1}
    tty: true
    restart: "always"
    depends_on:
      - mariadb
      - es01
      - es02
      - es03
      - activemq
      - mail
      - cassandra
    ports:
      - "8044:80"
    volumes:
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/data:/var/www/CONTENTSERV/${projectName}/data"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/templates:/var/www/CONTENTSERV/${projectName}/templates"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/volumes:/var/www/CONTENTSERV/${projectName}/volumes"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/modules:/var/www/CONTENTSERV/${projectName}/modules"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/plugins:/var/www/CONTENTSERV/${projectName}/plugins"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/logs:/var/log/apache2/"
    networks:
      - internal

  samba:
    environment:
      workspace: test
    labels:
      "traefik.enable": "false"
    image: ${sambaImage-registry.int.sup.sdzecom.de/runtime/production-samba:cs21.4.1}
    tty: true
    restart: "always"
    depends_on:
      - web
    # this is a big problem as parallel instances of content serv dockers are no longer possible
    ports:
      - "137:137"
      - "138:138"
      - "139:139"
      - "445:445"
    volumes:
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/data:/var/www/CONTENTSERV/${projectName}/data"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/templates:/var/www/CONTENTSERV/${projectName}/templates"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/volumes:/var/www/CONTENTSERV/${projectName}/volumes"      
    networks:
      - internal

  mail:
    environment:
      relayHost: ${relayHost}
      relayPort: ${relayHost-587}
      relayAuth: ${relayHost-yes}
      relayUsername: ${relayUsername-}
      relayPassword: ${relayPassword-}
      rewriteAddress: ${rewriteAddress-1}
      limitRecipientsDomain: ${limitRecipientsDomain-}
      senderAddress: ${senderAddress-}
    labels:
      "traefik.enable": "false"
    image: ${mailImage-registry.int.sup.sdzecom.de/runtime/production-mail:cs21.4.1}
    tty: true
    restart: "always"
    networks:
      - internal

  installer:
    environment:
      projectName: ${projectName}
      webHost: web
      elasticHost: elastic
      cassandraHost: cassandra
      activemqHost: activemq
      databaseHost: mariadb
      databaseName: ${databaseName-production}
      databaseUsername: ${databaseUsername-contentserv}
      databasePassword: ${databasePassword}
    labels:
      "traefik.enable": "false"
    image: ${installerImage-registry.int.sup.sdzecom.de/runtime/production-installer:cs21.4.1}
    tty: true
    restart: "no"
    volumes:
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/data:/var/www/CONTENTSERV/${projectName}/data"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/templates:/var/www/CONTENTSERV/${projectName}/templates"
      - "/daten/www/htdocs/CONTENTSERV/${projectName}/volumes:/var/www/CONTENTSERV/${projectName}/volumes"
    depends_on:
      - web
      - mariadb
    networks:
      - internal

volumes:
  es_data01:
    driver: local
  es_data02:
    driver: local
  es_data03:
    driver: local
  cas_data01:
    driver: local  
  cas_logs01:
    driver: local  
  mariadb-data:
    external: false
  mariadb-logs:
    external: false

networks:
  internal:
    driver: bridge
