version: '2.1'
#version: '3'

volumes:
  files:
    driver: local
    driver_opts: 
      type: volume 
      o: 'bind'
      device: "${DATA_VOLUME_ROOT}/data/files"
  db:
    driver: local
    driver_opts: 
      type: volume 
      o: 'bind'
      device: "${DB_VOLUME_ROOT}/db"

  redis:
    driver: local
    driver_opts: 
      type: volume 
      o: 'bind'
      device: "${REDIS_VOLUME_ROOT}/redis"

  es_index:
    driver: local
    driver_opts:
      type: volume 
      o: 'bind'
      device: "${ELASTIC_SEARCH_ROOT}/es"

  es_root:
    driver: local
    driver_opts:
      type: volume 
      o: 'bind'
      device: "${ELASTIC_SEARCH_ROOT}/es_root"


  oo_data:
    driver: local
    driver_opts: 
      type: volume 
      o: 'bind'
      device: "${DATA_VOLUME_ROOT}/data/oo_data"

services:
  db:
    image: mariadb
    container_name: ${CONTAINER_NAME}_db
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud


  redis:
    image: redis:alpine
    container_name: ${CONTAINER_NAME}_redis
    restart: "no"
    volumes:
      - redis:/var/lib/redis


  app:
    image: nextcloud
    container_name: ${CONTAINER_NAME}
    ports:
      - 1234:80
    links:
      - db
      - redis
    volumes:
      - files:/var/www/html
    restart: "no" 
    environment:
      - REDIS_HOST=redis
      - REDIS_PASSWORD=


  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.8.1
    container_name: ${CONTAINER_NAME}_es 
    environment:
      - node.name=es01
      - discovery.type=single-node
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      #- es_index:/usr/share/elasticsearch/data
      - es_index:/usr/share/elasticsearch/data
      #- es_root:/usr/share/elasticsearch
      - es_root:/usr/share/elasticsearch
    restart: "no" 
    ports:
      - 9200:9200

  onlyoffice:
    container_name: ${CONTAINER_NAME}_onlyoffice
    image: onlyoffice/documentserver:latest
    stdin_open: true
    tty: true
    restart: "no" 
    #restart: always
    ports:
      - 9980:80
    volumes:
      - oo_data:/var/www/onlyoffice/Data
      #- oo_log:/var/log/onlyoffice


  av:
    image: mkodockx/docker-clamav:alpine
    container_name: ${CONTAINER_NAME}_clamav 
    restart: "no" 
    ports:
      - 3310:3310
    #restart: unless-stopped
