Cirry's Blog

Docker安装immich图片备份工具

2022-09-27
docker
最后更新:2024-03-26
6分钟
1019字

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

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

页面展示

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

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

下载docker-compose

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

1
version: "3.8"
2
3
services:
4
immich-server:
5
image: altran1502/immich-server:latest
6
entrypoint: ["/bin/sh", "./start-server.sh"]
7
volumes:
8
- ${UPLOAD_LOCATION}:/usr/src/app/upload
9
env_file:
10
- .env
11
environment:
12
- NODE_ENV=production
13
depends_on:
14
- redis
15
- database
68 collapsed lines
16
restart: always
17
18
immich-microservices:
19
image: altran1502/immich-server:latest
20
entrypoint: ["/bin/sh", "./start-microservices.sh"]
21
volumes:
22
- ${UPLOAD_LOCATION}:/usr/src/app/upload
23
env_file:
24
- .env
25
environment:
26
- NODE_ENV=production
27
depends_on:
28
- redis
29
- database
30
restart: always
31
32
immich-machine-learning:
33
image: altran1502/immich-machine-learning:latest
34
entrypoint: ["/bin/sh", "./entrypoint.sh"]
35
volumes:
36
- ${UPLOAD_LOCATION}:/usr/src/app/upload
37
env_file:
38
- .env
39
environment:
40
- NODE_ENV=production
41
depends_on:
42
- database
43
restart: always
44
45
immich-web:
46
image: altran1502/immich-web:latest
47
entrypoint: ["/bin/sh", "./entrypoint.sh"]
48
env_file:
49
- .env
50
restart: always
51
52
redis:
53
container_name: immich_redis
54
image: redis:6.2
55
restart: always
56
57
database:
58
container_name: immich_postgres
59
image: postgres:14
60
env_file:
61
- .env
62
environment:
63
POSTGRES_PASSWORD: ${DB_PASSWORD}
64
POSTGRES_USER: ${DB_USERNAME}
65
POSTGRES_DB: ${DB_DATABASE_NAME}
66
PG_DATA: /var/lib/postgresql/data
67
volumes:
68
- pgdata:/var/lib/postgresql/data
69
restart: always
70
71
immich-proxy:
72
container_name: immich_proxy
73
image: altran1502/immich-proxy:latest
74
ports:
75
- 2283:8080 # 默认是2280端口,根据需要修改
76
logging:
77
driver: none
78
depends_on:
79
- immich-server
80
restart: always
81
82
volumes:
83
pgdata:

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

下载env文件

1
###################################################################################
2
# Database
3
###################################################################################
4
5
DB_HOSTNAME=immich_postgres # 可以修改为自己的postgres数据库
6
DB_USERNAME=postgres
7
DB_PASSWORD=postgres
8
DB_DATABASE_NAME=immich
9
10
# Optional Database settings:
11
# DB_PORT=5432
12
13
###################################################################################
14
# Redis
15
###################################################################################
54 collapsed lines
16
17
REDIS_HOSTNAME=immich_redis
18
19
# Optional Redis settings:
20
# REDIS_PORT=6379
21
# REDIS_DBINDEX=0
22
# REDIS_PASSWORD=
23
# REDIS_SOCKET=
24
25
###################################################################################
26
# Upload File Config
27
###################################################################################
28
29
## 这一行必须修改,改为你的相片存放目录,必须是绝对路径
30
UPLOAD_LOCATION=absolute_location_on_your_machine_where_you_want_to_store_the_backup
31
32
###################################################################################
33
# Log message level - [simple|verbose]
34
###################################################################################
35
36
LOG_LEVEL=simple
37
38
###################################################################################
39
# JWT SECRET
40
###################################################################################
41
42
## 这一行必须修改
43
## linux 环境下,可以使用命令: openssl rand -base64 128 生成
44
JWT_SECRET=randomstringthatissolongandpowerfulthatnoonecanguess
45
46
###################################################################################
47
# Reverse Geocoding
48
####################################################################################
49
50
# DISABLE_REVERSE_GEOCODING=false
51
52
# Reverse geocoding is done locally which has a small impact on memory usage
53
# This memory usage can be altered by changing the REVERSE_GEOCODING_PRECISION variable
54
# This ranges from 0-3 with 3 being the most precise
55
# 3 - Cities > 500 population: ~200MB RAM
56
# 2 - Cities > 1000 population: ~150MB RAM
57
# 1 - Cities > 5000 population: ~80MB RAM
58
# 0 - Cities > 15000 population: ~40MB RAM
59
60
# REVERSE_GEOCODING_PRECISION=3
61
62
####################################################################################
63
# WEB - Optional
64
####################################################################################
65
66
# Custom message on the login page, should be written in HTML form.
67
# 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>"
68
69
PUBLIC_LOGIN_PAGE_MESSAGE=

使用技巧

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

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

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

使用命令行安装immichCLI工具

Terminal window
1
npm i immich -g

批量上传文件夹:

Terminal window
1
immich upload --email testuser@email.com --password password --server http://192.168.1.216:2283/api -d your/target/directory
本文标题:Docker安装immich图片备份工具
文章作者:Cirry
发布时间:2022-09-27
版权声明:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
感谢大佬送来的咖啡☕
alipayQRCode
wechatQRCode