如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统

一、简介

PhotoPrism® 是一款由人工智能驱动的应用程序,用于浏览、组织和分享您的照片集。它利用最新技术自动标记和查找图片。您可以在家里、私人服务器或云端运行它。

PhotoPrism对很多设备提供了支持,包括Mac, Linux, Windows, DigitalOcean, Raspberry Pi, FreeBSD, 以及 NAS devices 。安装方面官方推荐使用Docker Compose进行安装。

二、功能概述

• 浏览你所有的照片和视频而不用担心格式转换,重复或视频格式问题
• 轻松地找到特定的图片查看具备强大的搜索过滤器
• 认识到你的家人和朋友的面孔(面部识别)
• 自动分类基于内容的图片和位置
• 将鼠标悬停在照片上面显示各种照片信息
• 实用好看的的WebUI界面,提供了自适配方案,您可以方便地在所有主流操作系统和移动设备查看你的照片
• 包括四个高分辨率的世界地图,带你回忆你最喜欢的旅行
• 元数据提取和合并Exif,XMP和其他来源,如谷歌照片
• 更多的图像属性颜色,浓度,质量供搜索
• 使用PhotoSync在后台安全地备份,有iOS和Android双端APP
• WebDAV服务,如微软的Windows Explorer和苹果的finder,可以直接连接PhotoPrism,允许您打开、编辑和删除文件,或者直接下载到本地

官网地址:https://docs.photoprism.app/

官方Demo地址:https://demo-zh.photoprism.app/

三、系统要求

根据官方建议CPU选项最少2核,内存选项最少4GB,如果服务器内存的交换空间小于4GB可能导致意外重启。

下图为虚拟机设定参数,设定量可根据宿主机配置灵活分配。

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第1张图片

由于我的服务器最大为6核,所以我这里设定为6核

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第2张图片

四、安装环境

系统:CentOS 7
服务器IP:192.168.50.101
域名:www.example.com

五、使用Docker Compose进行安装

借助Docker Compose,您可以使用 YAML 文件 来配置所有应用程序服务,这样您就可以轻松地使用单个命令启动它们。在继续之前,请确保您的系统上安装了Docker (Linux安装Docker教程)。

1、创建工作目录

mkdir -p /mnt/docker-volumes/photoprism

2、切换到工作目录

cd /mnt/docker-volumes/photoprism

3、下载官方docker-compose.yml示例

wget https://dl.photoprism.app/docker/docker-compose.yml

4、配置调整

PhotoPrism环境变量说明

变量 说明
PHOTOPRISM_ADMIN_USER 网页登录用户名
PHOTOPRISM_ADMIN_PASSWORD 网页登录密码
PHOTOPRISM_SITE_URL 网页访问地址
PHOTOPRISM_DATABASE_DRIVER 数据库驱动
PHOTOPRISM_DATABASE_SERVER 数据库主机IP及端口
PHOTOPRISM_DATABASE_NAME 数据库名称
PHOTOPRISM_DATABASE_USER 数据库用户名
PHOTOPRISM_DATABASE_PASSWORD 数据库密码

PhotoPrism卷挂载说明

容器目录 说明
/photoprism/originals 存放照片目录
/photoprism/storage 存放配置
/photoprism/import 导入文件目录

MariaDB环境变量说明

变量 说明
MARIADB_DATABASE 数据库名称
MARIADB_USER 数据库用户名
MARIADB_PASSWORD 数据库密码
MARIADB_ROOT_PASSWORD root密码

MariaDB卷挂载说明

容器目录 说明
/var/lib/mysql 数据库存放目录

调整后的docker-compose.yml内容如下:

version: '3.5'
services:
  photoprism:
    image: photoprism/photoprism:latest
    depends_on:
      - mariadb
    restart: unless-stopped
    security_opt:
      - seccomp:unconfined
      - apparmor:unconfined
    ports:
      - "2342:2342" # HTTP port (host:container)
    environment:
      PHOTOPRISM_ADMIN_USER: "admin"                 # admin username
      PHOTOPRISM_ADMIN_PASSWORD: "insecure"          # initial admin password (minimum 8 characters)
      PHOTOPRISM_AUTH_MODE: "password"               # authentication mode (public, password)
      PHOTOPRISM_SITE_URL: "http://www.example.com:2342/"  # server URL in the format "http(s)://domain.name(:port)/(path)"
      PHOTOPRISM_ORIGINALS_LIMIT: 5000               # 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: 85                    # 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)
      # PHOTOPRISM_DATABASE_DRIVER: "sqlite"         # SQLite is an embedded database that doesn't require a server
      PHOTOPRISM_DATABASE_DRIVER: "mysql"            # use MariaDB 10.5+ or MySQL 8+ instead of SQLite for improved performance
      PHOTOPRISM_DATABASE_SERVER: "mariadb:3306"     # MariaDB or MySQL database server (hostname:port)
      PHOTOPRISM_DATABASE_NAME: "photoprism"         # MariaDB or MySQL database schema name
      PHOTOPRISM_DATABASE_USER: "photoprism"         # MariaDB or MySQL database user name
      PHOTOPRISM_DATABASE_PASSWORD: "insecure"       # MariaDB or MySQL database user password
      PHOTOPRISM_SITE_CAPTION: "AI-Powered Photos App"
      PHOTOPRISM_SITE_DESCRIPTION: ""                # meta site description
      PHOTOPRISM_SITE_AUTHOR: ""                     # meta site author
    working_dir: "/photoprism" # do not change or remove
    volumes:
      - "/mnt/docker-volumes/photoprism/photos:/photoprism/originals"               # Original media files (DO NOT REMOVE)
      - "/mnt/docker-volumes/photoprism/config:/photoprism/storage"                 # *Writable* storage folder for cache, database, and sidecar files (DO NOT REMOVE)
      - "/mnt/docker-volumes/photoprism/import:/photoprism/import"

  ## Database Server (recommended)
  ## see https://docs.photoprism.app/getting-started/faq/#should-i-use-sqlite-mariadb-or-mysql
  mariadb:
    ## If MariaDB gets stuck in a restart loop, this points to a memory or filesystem issue:
    ## https://docs.photoprism.app/getting-started/troubleshooting/#fatal-server-errors
    restart: unless-stopped
    image: mariadb:10.9
    security_opt: # see https://github.com/MariaDB/mariadb-docker/issues/434#issuecomment-1136151239
      - seccomp:unconfined
      - apparmor:unconfined
    command: mysqld --innodb-buffer-pool-size=512M --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
    ## Never store database files on an unreliable device such as a USB flash drive, an SD card, or a shared network folder:
    volumes:
      - "/mnt/docker-volumes/photoprism/database:/var/lib/mysql" # DO NOT REMOVE
    environment:
      MARIADB_AUTO_UPGRADE: "1"
      MARIADB_INITDB_SKIP_TZINFO: "1"
      MARIADB_DATABASE: "photoprism"
      MARIADB_USER: "photoprism"
      MARIADB_PASSWORD: "insecure"
      MARIADB_ROOT_PASSWORD: "insecure"

  ## Watchtower upgrades services automatically (optional)
  ## see https://docs.photoprism.app/getting-started/updates/#watchtower
  ## activate via "COMPOSE_PROFILES=update docker compose up -d"
  watchtower:
    restart: unless-stopped
    image: containrrr/watchtower
    profiles: ["update"]
    environment:
      WATCHTOWER_CLEANUP: "true"
      WATCHTOWER_POLL_INTERVAL: 7200 # checks for updates every two hours
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      #- "~/.docker/config.json:/config.json" # optional, for authentication if you have a Docker Hub account

5、启动容器

docker-compose up -d

6、访问服务

http://www.example.com:2342

账号为 admin,密码就是我们在 PHOTOPRISM_ADMIN_PASSWORD 中设置的值

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第3张图片

登录成功后进入主界面,此时还未上传图片,所以主界面是空的

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第4张图片

设置中文

左侧菜单 settings --> GENERAL --> Language 中下拉找到 简体中文

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第5张图片

界面会自动刷新

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第6张图片

六、备份与同步

使用 PhotoSync 在后台安全地备份 iOS 和 Android 手机。Microsoft 的 Windows Explorer 和 Apple 的 Finder 等 WebDAV 客户端可以直接连接到 PhotoPrism,让您可以像在本地一样打开、编辑和删除计算机中的文件。

1、下载手机应用PhotoSync

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第7张图片

2、配置PhotoPrism

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第8张图片

3、输入服务器信息

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第9张图片

配置完成后在APP首页点击右上角 “同步” 按钮,即可开始同步手机照片到服务器。

如何使用Docker搭建PhotoPrism - 打造基于AI私有化的个人相册系统_第10张图片

你可能感兴趣的:(软件工具,Docker,docker,人工智能,容器)