version: '3.8'

networks:
  nextcloud-internal:
    driver: bridge

services:
  nextcloud-db:
    image: mariadb:10.6
    container_name: nextcloud-db
    restart: unless-stopped
    volumes:
      - ~/nextcloud/mariadb:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=YourStrongRootPasswordHere
      - MYSQL_PASSWORD=YourStrongDatabasePasswordHere
      - MYSQL_DATABASE=nextcloud1
      - MYSQL_USER=nextcloud
    networks:
      - nextcloud-internal

  nextcloud-redis:
    image: redis:alpine
    container_name: nextcloud-redis
    environment:
      - redis.session.locking_enabled=1
      - redis.session.lock_retries=-1
      - redis.session.lock_wait_time=10000

    restart: unless-stopped
    networks:
      - nextcloud-internal

  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: unless-stopped
    depends_on:
      - nextcloud-db
      - nextcloud-redis
    volumes:
      - ~/nextcloud/data:/var/www/html
      - ~/nextcloud/config:/var/www/html/config
      - ~/nextcloud/custom_apps:/var/www/html/custom_apps
      - ~/nextcloud/themes:/var/www/html/themes
    environment:
      - MYSQL_PASSWORD=YourStrongDatabasePasswordHere
      - MYSQL_DATABASE=nextcloud1
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=nextcloud-db
      - REDIS_HOST=nextcloud-redis
      - NEXTCLOUD_TRUSTED_DOMAINS=localhost,nextcloud.local,192.168.50.66,100.98.144.95, 
    ports:
      - "8080:80"
    networks:
      - nextcloud-internal