Cirry's Blog

Docker安装immich图片备份工具

Sep 27, 2022
docker docker
6分钟
1022字

immich是一个开源、高性能的自托管备份解决方案,用于在手机上备份视频和照片。支持多端通用,非常小巧。

An open source, high performance self-hosted backup solution for videos and photos on your mobile phone。

页面展示

default

default

default

default

default

经过几天的使用,我感觉这个软件要是能做出来,还是相当的厉害的,但是目前的问题也很多,如果不是大佬或者不能给这个项目提pr的能力,建议不要深度使用,不是很稳定,而且有不少问题。

  1. 已经存在的历史图片必须一张一张上传,上传过程中cpu会被占满,我的i3-10105,100%使用持续大概12个小时。
  2. 手机备份经常把照片来回备份,即已经备份过的照片再上传一次,实际上服务器没有保存。
  3. docker子服务经常崩溃。

下载docker-compose

以下内容只有一个地方可能需要修改,就是暴露端口号。

version: "3.8"
services:
immich-server:
image: altran1502/immich-server:latest
entrypoint: ["/bin/sh", "./start-server.sh"]
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
env_file:
- .env
environment:
- NODE_ENV=production
depends_on:
- redis
- database
68 collapsed lines
restart: always
immich-microservices:
image: altran1502/immich-server:latest
entrypoint: ["/bin/sh", "./start-microservices.sh"]
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
env_file:
- .env
environment:
- NODE_ENV=production
depends_on:
- redis
- database
restart: always
immich-machine-learning:
image: altran1502/immich-machine-learning:latest
entrypoint: ["/bin/sh", "./entrypoint.sh"]
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
env_file:
- .env
environment:
- NODE_ENV=production
depends_on:
- database
restart: always
immich-web:
image: altran1502/immich-web:latest
entrypoint: ["/bin/sh", "./entrypoint.sh"]
env_file:
- .env
restart: always
redis:
container_name: immich_redis
image: redis:6.2
restart: always
database:
container_name: immich_postgres
image: postgres:14
env_file:
- .env
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
PG_DATA: /var/lib/postgresql/data
volumes:
- pgdata:/var/lib/postgresql/data
restart: always
immich-proxy:
container_name: immich_proxy
image: altran1502/immich-proxy:latest
ports:
- 2283:8080 # 默认是2280端口,根据需要修改
logging:
driver: none
depends_on:
- immich-server
restart: always
volumes:
pgdata:

我本来是跟官网同步下载的release版本,但是发现有bug,改成了lastest版本了。

下载env文件

###################################################################################
# Database
###################################################################################
DB_HOSTNAME=immich_postgres # 可以修改为自己的postgres数据库
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich
# Optional Database settings:
# DB_PORT=5432
###################################################################################
# Redis
###################################################################################
54 collapsed lines
REDIS_HOSTNAME=immich_redis
# Optional Redis settings:
# REDIS_PORT=6379
# REDIS_DBINDEX=0
# REDIS_PASSWORD=
# REDIS_SOCKET=
###################################################################################
# Upload File Config
###################################################################################
## 这一行必须修改,改为你的相片存放目录,必须是绝对路径
UPLOAD_LOCATION=absolute_location_on_your_machine_where_you_want_to_store_the_backup
###################################################################################
# Log message level - [simple|verbose]
###################################################################################
LOG_LEVEL=simple
###################################################################################
# JWT SECRET
###################################################################################
## 这一行必须修改
## linux 环境下,可以使用命令: openssl rand -base64 128 生成
JWT_SECRET=randomstringthatissolongandpowerfulthatnoonecanguess
###################################################################################
# Reverse Geocoding
####################################################################################
# DISABLE_REVERSE_GEOCODING=false
# Reverse geocoding is done locally which has a small impact on memory usage
# This memory usage can be altered by changing the REVERSE_GEOCODING_PRECISION variable
# This ranges from 0-3 with 3 being the most precise
# 3 - Cities > 500 population: ~200MB RAM
# 2 - Cities > 1000 population: ~150MB RAM
# 1 - Cities > 5000 population: ~80MB RAM
# 0 - Cities > 15000 population: ~40MB RAM
# REVERSE_GEOCODING_PRECISION=3
####################################################################################
# WEB - Optional
####################################################################################
# Custom message on the login page, should be written in HTML form.
# For example PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email: <i>demo@demo.de</i><br>Password: <i>demo</i>"
PUBLIC_LOGIN_PAGE_MESSAGE=

使用技巧

这个软件的全平台通用非常好用,苹果特有的heic格式也支持。

现在有一个使用场景如下:

曾经用过其他的图片管理工具,或者电脑上已经有很多图片了,现在需要转移到immich中。如果我们直接把以前的图片文件复制到immich中会发现在网页端不会显示,因为immich要给每一个图片和视频进行解码和生成缩略图,你直接复制进去,他就没办法生成了,也就没办法展示了,在github中曾经有人提过这个问题,最后开发者说因为要生成记录到数据库,必须每个图片都上传一下才行。如果一个人有很多张图片,这样传太废时间,而且我发现网页端的上传功能有两个问题,一是会自动忽略文件夹中的heic文件上传,二是不能一下上传50张以上的图片,会给个提示让用命令行上传。我就去找了下命令行的文档,发现命令行的文档里还明确写了支持heic格式,经过测试也确实支持,这也解决了ios端的一个大问题,但是我还是建议ios关闭这个heic格式。

使用命令行安装immichCLI工具

Terminal window
npm i immich -g

批量上传文件夹:

Terminal window
immich upload --email testuser@email.com --password password --server http://192.168.1.216:2283/api -d your/target/directory
本文标题:Docker安装immich图片备份工具
文章作者:Cirry
发布时间:Sep 27, 2022
感谢大佬送来的咖啡☕
alipayQRCode
wechatQRCode
总访问量
总访客数人次