services:
  db:
    image: mariadb:10.11
    restart: unless-stopped
    env_file: .env
    volumes:
      - db_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 5

  nextcloud:
    image: nextcloud:28-apache
    restart: unless-stopped
    ports:
      - "8080:80"
    # Use public resolvers instead of inheriting the host's resolver.
    # The host may synthesize IPv6-only NAT64 addresses (64:ff9b::/96) which
    # an IPv4-only container cannot reach, breaking outbound HTTPS calls
    # (self-update check, calendar/contacts sync, etc.).
    dns:
      - 1.1.1.1
      - 8.8.8.8
    env_file: .env
    environment:
      MYSQL_HOST: db
      NEXTCLOUD_TRUSTED_DOMAINS: "localhost,192.168.2.35"
      OVERWRITEHOST: "192.168.2.35"
    volumes:
      - nc_data:/var/www/html
      - ./:/app-src:ro
    depends_on:
      db:
        condition: service_healthy

volumes:
  db_data:
  nc_data:
