---
version: '3.7'

volumes:
  photoprism-database:
    name: datastore/appdata/photoprism/database
    driver: glusterfs
  photoprism-metadata:
    name: datastore/appdata/photoprism/metadata
  photoprism-originals:
    name: datastore/media/photoprism
    driver: glusterfs
  photoprism-import:
    name: datastore/media/upload
    driver: glusterfs

networks:
  photoprism:
    internal: true
    name: photoprism
    driver: overlay
    ipam:
      driver: default
      config:
        - subnet: 192.168.109.0/24

services:
  app:
    image: photoprism/photoprism:latest
    hostname: app
    depends_on:
      - database
    networks:
      - photoprism
    ports:
      - published: 2342
        target: 2342
        protocol: tcp
        mode: ingress
    environment:
      PHOTOPRISM_ADMIN_PASSWORD: "gm2auW34GNawZ8Dqiub8W8vOlvsHCnfj"
      PHOTOPRISM_SITE_URL: "http://cluster.skylab.enp.one:2342/"
      PHOTOPRISM_ORIGINALS_LIMIT: 5000
      PHOTOPRISM_HTTP_COMPRESSION: "gzip"
      PHOTOPRISM_DEBUG: "false"
      PHOTOPRISM_PUBLIC: "false"
      PHOTOPRISM_READONLY: "false"
      PHOTOPRISM_EXPERIMENTAL: "false"
      PHOTOPRISM_DISABLE_CHOWN: "false"
      PHOTOPRISM_DISABLE_WEBDAV: "false"
      PHOTOPRISM_DISABLE_SETTINGS: "false"
      PHOTOPRISM_DISABLE_TENSORFLOW: "false"
      PHOTOPRISM_DISABLE_FACES: "false"
      PHOTOPRISM_DISABLE_CLASSIFICATION: "false"
      PHOTOPRISM_DARKTABLE_PRESETS: "false"
      PHOTOPRISM_DETECT_NSFW: "false"
      PHOTOPRISM_UPLOAD_NSFW: "true"
      PHOTOPRISM_DATABASE_DRIVER: "mysql"
      PHOTOPRISM_DATABASE_SERVER: "database:3306"
      PHOTOPRISM_DATABASE_NAME: "photoprism"
      PHOTOPRISM_DATABASE_USER: "photoprism"
      PHOTOPRISM_DATABASE_PASSWORD: "KcIKhME9OwWKVz4tGyqI4VXzyDBs33Xp"       # MariaDB or MySQL database user password
      PHOTOPRISM_SITE_TITLE: "Skylab Images"
      PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
      PHOTOPRISM_SITE_DESCRIPTION: ""
      PHOTOPRISM_SITE_AUTHOR: "EN Paul"
      HOME: "/photoprism"
      PHOTOPRISM_UID: 1408
      PHOTOPRISM_GID: 1408
      ## Hardware video transcoding config (optional)
      # PHOTOPRISM_FFMPEG_BUFFERS: "64"              # FFmpeg capture buffers (default: 32)
      # PHOTOPRISM_FFMPEG_BITRATE: "32"              # FFmpeg encoding bitrate limit in Mbit/s (default: 50)
      # PHOTOPRISM_FFMPEG_ENCODER: "h264_v4l2m2m"    # Use Video4Linux for AVC transcoding (default: libx264)
      # PHOTOPRISM_FFMPEG_ENCODER: "h264_qsv"        # Use Intel Quick Sync Video for AVC transcoding (default: libx264)
      # PHOTOPRISM_INIT: "intel-graphics tensorflow-amd64-avx2" # Enable TensorFlow AVX2 & Intel Graphics support
      ## Enable TensorFlow AVX2 support for modern Intel CPUs (requires starting the container as root)
      # PHOTOPRISM_INIT: "tensorflow-amd64-avx2"
    user: "1408:1408"
    working_dir: "/photoprism"
    volumes:
      - type: volume
        source: photoprism-originals
        target: /photoprism/originals
        read_only: false
      - type: volume
        source: photoprism-metadata
        target: /photoprism/storage
        read_only: false
      - type: volume
        source: photoprism-import
        target: /photoprism/import
        read_only: true
    deploy:
      replicas: 1

  database:
    image: mariadb:10.6
    hostname: database
    command: mysqld --innodb-buffer-pool-size=128M --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=120
    networks:
      - photoprism
    volumes:
      - type: volume
        source: photoprism-database
        target: /var/lib/mysql
        read_only: false
    environment:
      MYSQL_ROOT_PASSWORD: insecure
      MYSQL_DATABASE: photoprism
      MYSQL_USER: photoprism
      MYSQL_PASSWORD: KcIKhME9OwWKVz4tGyqI4VXzyDBs33Xp
    deploy:
      replicas: 1
