version: "3.5"

services:
  photoprism-tplm:
    image: photoprism/photoprism:latest
    container_name: "photoprism-tplm"
    depends_on:
      - photoprism-tplm-mariadb
    restart: unless-stopped
    user: 1000:1000 
    ports:
      - "2344:2344" # HTTP port (host:container)
    environment:
      PHOTOPRISM_HTTP_PORT : 2344
      VIRTUAL_HOST: photo-tplm.micard-family.fr
      LETSENCRYPT_HOST: photo-tplm.micard-family.fr
      LETSENCRYPT_EMAIL: emilien.micard@gmail.com
      VIRTUAL_PORT: 2344
      PHOTOPRISM_ADMIN_PASSWORD: ${PHOTOPRISM_ADMIN_PASSWORD}
      PHOTOPRISM_SITE_URL: https://photo-tplm.micard-family.fr
      PHOTOPRISM_DATABASE_DRIVER: "mysql" 
      PHOTOPRISM_DATABASE_SERVER: "photoprism-tplm-mariadb:3306"
      PHOTOPRISM_DATABASE_NAME: "photoprism" 
      PHOTOPRISM_DATABASE_USER: "photoprism"
      PHOTOPRISM_DATABASE_PASSWORD: 67hzL64eYX
      PHOTOPRISM_SITE_TITLE: "PhotoPrism"
      PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
      PHOTOPRISM_SITE_DESCRIPTION: ""
      PHOTOPRISM_SITE_AUTHOR: ""
      HOME: "/photoprism"

      PHOTOPRISM_ORIGINALS_LIMIT: 10000               # file size limit for originals in MB (increase for high-res video)
      PHOTOPRISM_HTTP_COMPRESSION: "gzip"            # improves transfer speed and bandwidth utilization (none or gzip)
      PHOTOPRISM_LOG_LEVEL: "info"                   # log level: trace, debug, info, warning, error, fatal, or panic
      PHOTOPRISM_READONLY: "false"                   # do not modify originals directory (reduced functionality)
      PHOTOPRISM_EXPERIMENTAL: "false"               # enables experimental features
      PHOTOPRISM_DISABLE_CHOWN: "false"              # disables updating storage permissions via chmod and chown on startup
      PHOTOPRISM_DISABLE_WEBDAV: "false"             # disables built-in WebDAV server
      PHOTOPRISM_DISABLE_SETTINGS: "false"           # disables settings UI and API
      PHOTOPRISM_DISABLE_TENSORFLOW: "false"         # disables all features depending on TensorFlow
      PHOTOPRISM_DISABLE_FACES: "false"              # disables face detection and recognition (requires TensorFlow)
      PHOTOPRISM_DISABLE_CLASSIFICATION: "false"     # disables image classification (requires TensorFlow)
      PHOTOPRISM_DISABLE_RAW: "false"                # disables indexing and conversion of RAW files
      PHOTOPRISM_RAW_PRESETS: "false"                # enables applying user presets when converting RAW files (reduces performance)
      PHOTOPRISM_JPEG_QUALITY: 80                    # a higher value increases the quality and file size of JPEG images and thumbnails (25-100)
      PHOTOPRISM_DETECT_NSFW: "false"                # automatically flags photos as private that MAY be offensive (requires TensorFlow)
      PHOTOPRISM_UPLOAD_NSFW: "true"                 # allows uploads that MAY be offensive (no effect without TensorFlow)
     
    working_dir: "/photoprism"
    volumes:
      - /mnt/data/TPLM/medias/photos:/photoprism/originals
      - /mnt/data/docker-storage/photoprism-tplm-storage:/photoprism/storage                # *Writable* storage folder for cache, database, and sidecar files (DO NOT REMOVE)

    labels:
      ofelia.enabled: "true"
      ofelia.job-exec.photoprism_index.schedule: "@every 1h"
      ofelia.job-exec.photoprism_index.command: "photoprism index --cleanup"

  photoprism-tplm-mariadb:
    restart: unless-stopped
    container_name: "photoprism-tplm-db"
    image: mariadb:10.6
    ports:
      - "33007:3306" # MySQL port (host:container)
    security_opt:
      - seccomp:unconfined
      - apparmor:unconfined
    command: mysqld --innodb-buffer-pool-size=256M --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
    volumes:
      - "./db:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: S8mQ5MDJhv
      MYSQL_DATABASE: photoprism
      MYSQL_USER: photoprism
      MYSQL_PASSWORD: 67hzL64eYX

  ofelia-tplm:
    restart: unless-stopped
    image: mcuadros/ofelia:latest
    container_name: ofelia-tplm
    depends_on:
      - photoprism-tplm
    command: daemon --docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

  backup-photoprism-tplm:
    image: databack/mysql-backup
    container_name: "photoprism-tplm-db-backup"
    restart: always
    user : 0:0
    depends_on:
      - photoprism-tplm-mariadb
    volumes:
     - /mnt/data/docker-backups/photoprism-tplm-db:/db
    # - /path/to/pre-backup/scripts:/scripts.d/pre-backup
    # - /path/to/post-backup/scripts:/scripts.d/post-backup
    environment:
     - DB_DUMP_TARGET=/db
     - DB_USER=photoprism
     - DB_PASS=67hzL64eYX
     - DB_DUMP_FREQ=1440
     - DB_DUMP_BEGIN=+1
     - DB_SERVER=photoprism-tplm-mariadb

  
  dbadmin-photoprism-tplm: # Nom du micro service PhpMyAdmin
    image: phpmyadmin # Basée sur une image officielle phpmyadmin (dockerhub)
    container_name: "photoprism-tplm-db-admin"
    restart: always # Politique de redémarrage lorsque le serveur redémarre 
    ports:
      - '8889:80' # Port d'accès à la page web d'admin de PhpMyAdmin
    environment:
      PMA_HOST: photoprism-tplm-mariadb # Hostname (nom du micro-service dans la stack) du conteneur de BDD
      UPLOAD_LIMIT: 900M
    depends_on:
      - photoprism-tplm-mariadb  # Pour forcer l'ordre de démarrage des conteneurs

networks:
    default:
        external:
            name: proxy_nginxproxy
