services:

  cloud:
    image: nextcloud
    container_name: ${nextcloudServName}
    restart: ${restartPolicy}
    depends_on:
      - db
    links:
      - db
    external_links:
      - ${smtpServName}:${smtpHost}
    # ports:
    #   - 8090:80
    networks:
      - cloudNet
      - postfixNet
      - ldapNet
    volumes:
      - cloudMain:/var/www/html
      - cloudData:/var/www/html/data
      - cloudConfig:/var/www/html/config
      - cloudApps:/var/www/html/apps
      - cloudCustomApps:/var/www/html/custom_apps
      - cloudThemes:/var/www/html/themes/
      - cloudPhp:/usr/local/etc/php/conf.d/
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    env_file:
      - ../../secret/env-${nextcloudServName}
      - ../../secret/env-${nextcloudDBName}
    environment:
      - NEXTCLOUD_TRUSTED_DOMAINS=${cloudHost}.${domain}
      - SMTP_HOST=${smtpHost}
      - SMTP_PORT=25
      - MAIL_DOMAIN=${domain}
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${nextcloudServName}.rule=Host(`${cloudHost}.${domain}`)"      
      - "traefik.docker.network=cloudNet"

  db:
    image: mariadb:10.5
    container_name: ${nextcloudDBName}
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: ${restartPolicy}
    volumes:
      - cloudDB:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    env_file:
      - ../../secret/env-${nextcloudDBName}
    networks:
      - cloudNet

volumes:
  cloudDB:
  cloudMain:
  cloudData:
  cloudConfig:
  cloudApps:
  cloudCustomApps:
  cloudThemes:
  cloudPhp:

networks:
  cloudNet:
    external: true
    name: cloudNet
  postfixNet:
    external: true
    name: postfixNet
  ldapNet:
    external: true
    name: ldapNet
