version: '3'

services:
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_ROOT_PASSWORD=
      # must be the same as db.env DB_USER
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD={{ enough_nextcloud_db_password | default('82v8ggh3', true) }}

  app:
    image: nextcloud:{{ enough_nextcloud_version }}-fpm-cron
    restart: always
    volumes:
      - nextcloud:/var/www/html
{% if  certificate_authority != 'letsencrypt' %}
      - /etc/ssl/certs:/etc/ssl/certs:ro
      - /usr/local/share/ca-certificates/infrastructure:/usr/local/share/ca-certificates/infrastructure:ro
{% endif %}
    environment:
      - DB_PASSWORD={{ enough_nextcloud_db_password | default('82v8ggh3', true) }}
    env_file:
      - db.env
    depends_on:
      - db


  web:
    build: ./web
    restart: always
    ports:
      - {{ enough_nextcloud_port }}:80
    volumes:
      - nextcloud:/var/www/html:ro
{% if  certificate_authority != 'letsencrypt' %}
      - /etc/ssl/certs:/etc/ssl/certs:ro
      - /usr/local/share/ca-certificates/infrastructure:/usr/local/share/ca-certificates/infrastructure:ro
{% endif %}
    depends_on:
      - app

volumes:
  db:
  nextcloud:
