### https://github.com/nextcloud/docker
## https://blog.ssdnodes.com/blog/installing-nextcloud-docker/
# https://docs.nextcloud.com/server/16/admin_manual/configuration_server/config_sample_php_parameters.html

# SERV='localhost' docker-compose -f docker-compose-nextcloud.yml up -d
# SERV='localhost' docker-compose -f docker-compose-nextcloud.yml ps
# SERV='localhost' docker-compose -f docker-compose-nextcloud.yml logs nextcloud
# SERV='localhost' docker-compose -f docker-compose-nextcloud.yml exec nextcloud bash

version: '2'

volumes:
  nextcloud:
  ncdb:

services:
  ncdb:
    image: mariadb
    container_name: db
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: unless-stopped
    labels:
       - traefik.enable=false
       - traefik.docker.network=traefik
    volumes:
      - ncdb:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=Contrasenna
      - MYSQL_PASSWORD=Contrasenna
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    networks:
       - nc_back

  nextcloud:
    image: nextcloud
    container_name: nextcloud
    depends_on:
      - ncdb
    volumes:
      - nextcloud:/var/www/html
    labels:
      - "traefik.enable=true"
      - "traefik.port=80"
      - "traefik.backend=nextcloud"
#      - "traefik.frontend.rule=Host:${SERV}; PathPrefixStrip:/nextcloud"
      - "traefik.frontend.rule=Host:nextcloud.${SERV}"
      - "traefik.docker.network=traefik"
    environment:
      - NEXTCLOUD_ADMIN_USER=Pablo
      - NEXTCLOUD_ADMIN_PASSWORD=Contrasenna
      - SMTP_HOST=smtp.ehu.eus
      - LC_ALL=C.UTF-8
      - TZ=Europe/Madrid
    restart: unless-stopped
    networks:
      - traefik
      - nc_back
networks:
  nc_back:
    driver: bridge
  traefik:
    external:
      name: traefik
