# vim: ft=yaml.docker-compose
version: "3.8"

services:
  postgres:
    image: postgres:{{ services.nextcloud.postgres_version }}
    restart: unless-stopped
    volumes:
      - "./postgres:/var/lib/postgresql/data"
    environment:
      POSTGRES_DB: nextcloud
      POSTGRES_PASSWORD: "{{ postgres_passwords.nextcloud }}"
      POSTGRES_USER: nextcloud

  redis:
    image: redis:{{ services.nextcloud.redis_version }}
    restart: unless-stopped
    command: redis-server --requirepass {{ nextcloud_secrets.redis_password }}
    tmpfs:
      - /var/lib/redis

  cron:
    image: nextcloud:{{ services.nextcloud.version }}
    restart: unless-stopped
    entrypoint: /cron.sh
    volumes:
      - "./app:/var/www/html"
    depends_on:
      - postgres
      - redis

  app:
    image: nextcloud:{{ services.nextcloud.version }}
    restart: unless-stopped
    networks:
      - default
      - postfix
      - external_services
    volumes:
      - "./app:/var/www/html"
    environment:
      VIRTUAL_HOST: "{{ services.nextcloud.domain }}"
      LETSENCRYPT_HOST: "{{ services.nextcloud.domain }}"
      LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}"
      POSTGRES_HOST: postgres
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: "{{ postgres_passwords.nextcloud }}"
      REDIS_HOST: redis
      REDIS_HOST_PASSWORD: "{{ nextcloud_secrets.redis_password }}"
    depends_on:
      - postgres
      - redis

networks:
  postfix:
    external: true
  external_services:
    external: true