---
services:
  nextcloud:
    image: git.hamburg.ccc.de/ccchh/oci-images/nextcloud:{{ nextcloud__version }}
    pull_policy: always
    restart: unless-stopped
    ports:
      - "8080:80"
    depends_on:
      - db
      - redis
    networks:
      - nextcloud
    volumes:
{% if nextcloud__use_custom_new_user_skeleton %}
      - "./custom_new_user_skeleton:/custom_new_user_skeleton"
{% endif %}
      - "./nextcloud_var_www_html:/var/www/html"
      - "{{ nextcloud__data_dir }}:/var/www/html/data"
    environment:
      POSTGRES_HOST: db
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: "{{ nextcloud__postgres_password }}"
      NEXTCLOUD_ADMIN_USER: admin
      NEXTCLOUD_ADMIN_PASSWORD: "{{ nextcloud__admin_password }}"
      REDIS_HOST: redis
      NEXTCLOUD_TRUSTED_DOMAINS: "{{ nextcloud__fqdn }}"
      # See here: https://github.com/nextcloud/docker#using-the-apache-image-behind-a-reverse-proxy-and-auto-configure-server-host-and-protocol
      APACHE_DISABLE_REWRITE_IP: 1
      TRUSTED_PROXIES: 127.0.0.1
      OVERWRITECLIURL: "https://{{ nextcloud__fqdn }}/"
      OVERWRITEHOST: "{{ nextcloud__fqdn }}"
      OVERWRITEPROTOCOL: "https"
    
  db:
    image: postgres:{{ nextcloud__postgres_version }}
    restart: unless-stopped
    #ports:
    #  - 127.0.0.1:5432:5432
    networks:
      - nextcloud
    volumes:
      - "./database:/var/lib/postgresql/data"
    environment:
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: "{{ nextcloud__postgres_password }}"

  redis:
    image: redis:alpine
    restart: unless-stopped
    networks:
      - nextcloud

networks:
  nextcloud:
    external: false