version: '3.9'

services:
  db:
    image: postgres:15-alpine
    restart: unless-stopped
    volumes:
      - db:/var/lib/postgresql/data:Z
    env_file:
      - db.env
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    logging:
      driver: "json-file"
      options:
        max-size: "5m"
        max-file: "1"

  app:
    image: nextcloud:production-apache
    restart: unless-stopped
    volumes:
      - app:/var/www/html:z
      - data:/data:z
    env_file:
      - db.env
      - nextcloud.env
    depends_on:
      - db
      - redis
    networks:
      - proxy
      - default
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  cron:
    image: nextcloud:production-apache
    restart: unless-stopped
    volumes:
      - app:/var/www/html:z
      - data:/data:z
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

volumes:
  db:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: "/srv/docker/nextcloud/db"
  app:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: "/srv/docker/nextcloud/app"
  data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: "/srv/mnt/nextcloud/data"

networks:
  proxy:
    external: true