version: '3.9'

services:
  nextcloud:
    image: nextcloud:27.1.3
    environment:
      - MYSQL_HOST=nextcloud-db
      - MYSQL_DATABASE=nextcloud1
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=YourStrongDatabasePasswordHere
      - REDIS_HOST=redis_redis_master
      - NEXTCLOUD_TRUSTED_DOMAINS=localhost,nextcloud.local,192.168.50.229,192.168.50.229:8082,nextcloud.pressmess.duckdns.org
    volumes:
      - /export/nextcloud:/var/www/html
      - /srv/dev-disk-by-uuid-0f772f0b-917d-4337-a3c5-5cc5d3badac9/nextcloud-db:/var/www/html/data
    ports:
      - "8082:80"
    networks:
      - caddy-public
      - database-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/status.php"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 90s
    deploy:
      resources:
        limits:
          memory: 2G
          cpus: '1.0'
        reservations:
          memory: 512M
          cpus: '0.25'
      placement:
        constraints:
          - node.role == manager
      replicas: 1

networks:
  caddy-public:
    external: true
  database-network:
    external: true
