services:
  excalidraw:
    container_name: excalidraw
    image: docker.io/excalidraw/excalidraw:latest
    restart: unless-stopped
    ports:
      - "3009:80"
    environment:
      - NODE_ENV=production
      - TZ=Europe/Zurich

  # Database (PostgreSQL)
  next-db:
    image: docker.io/postgres:18
    container_name: next-db
    environment:
      - POSTGRES_DB=${DB_DATABASE_NAME}
      - POSTGRES_USER=${DB_USERNAME}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    volumes:
      -
    restart: unless-stopped
    networks:
      - nextcloud_network

  # # Redis Cache
  # next_redis:
  #   image: docker.io/redis:latest
  #   container_name: next-redis
  #   command: redis-server --save 60 1 --loglevel warning
  #   volumes:
  #     - ./data/redis:/data
  #   restart: unless-stopped
  #   networks:
  #     - nextcloud_network

  # Nextcloud Main Application
  next:
    image: docker.io/nextcloud:latest
    container_name: next
    depends_on:
      - next-db
    mem_swappiness: -1
    ports:
      - "8808:80"
    environment:
      - POSTGRES_DB=${DB_DATABASE_NAME}
      - POSTGRES_USER=${DB_USERNAME}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_HOST=${DB_HOST}
      - NEXTCLOUD_TRUSTED_DOMAINS=next.liphlink.xyz
      - NEXTCLOUD_ADMIN_USER=liph
      - NEXTCLOUD_ADMIN_PASSWORD=1ChagenexT
    volumes:
      - :/var/www/html
      - :/var/www/html/config:Z
      - :/var/www/html/custom_apps
    restart: unless-stopped
    networks:
      - nextcloud_network

  # OnlyOffice (alternative to Collabora)
  onlyoffice:
    image: docker.io/onlyoffice/documentserver:latest
    container_name: onlyoffice
    ports:
      - 8000:80
    environment:
      # - JWT_SECRET='S2jaRmOxSxnFoOMhzXotL1QTptDuqhom'
      - JWT_ENABLED=false
      - JWT_HEADER=Authorization
      - JWT_IN_BODY=true
    volumes:
      - :/var/www/onlyoffice/Data
    restart: unless-stopped
    networks:
      - nextcloud_network

  obsidian:
    image: lscr.io/linuxserver/obsidian:latest
    container_name: obsidian
    security_opt:
      - seccomp:unconfined #optional
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - :/config:z
      - :/vault:z
    ports:
      - 3005:3000
      - 3004:3001
    shm_size: "1gb"
    restart: unless-stopped

volumes:
  pg_data:
  redis_data:
  nextcloud_data:
  nextcloud_config:
  nextcloud_apps:
  nextcloud_db_data:
  onlyoffice_data:

networks:
  nextcloud_network:
    name: nextcloud_network
