在centos上安装immich

一直在研究怎么把自己的上万张照片找一个合适的地方放置,目前还没有定论,但是比较倾向于immich.app.

记录在centos上的安装过程。

安装docker-ce

  1. enable 阿里云里的docker-ce的repo

    1
    2
    yum install -y yum-utils
    yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  2. yum安装docker-ce

    1
    yum install -y docker-ce docker-ce-cli --nobest --skip-broken
  3. 启动docker-ce

    1
    2
    3
    systemctl enable docker
    systemctl start docker
    systemctl status docker # 检查是不是启动成功

通过docker compose安装immich.app

  1. 创建目录
    如果挂载了多个磁盘,建议选择一个合适的目录,immich启动后会挂载全部的所在目录。

    1
    2
    mkdir ./immich-app
    cd ./immich-app
  2. 准备 docker-compose.yml 和 example.env
    下载文件:

    1
    2
    wget https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
    wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env

    下载后docker-compose.yml需要改动一下镜像的地址,换成国内的源。
    github的镜像源ghcr.io可以换成南京大学的ghcr.nju.edu.cn,默认dockerhub的源换成docker.nju.edu.cn,国内访问速度比较快。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    version: "3.8"

    services:
    immich-server:
    container_name: immich_server
    image: ghcr.nju.edu.cn/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "immich" ]
    volumes:
    - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
    - .env
    depends_on:
    - redis
    - database
    - typesense
    restart: always

    immich-microservices:
    container_name: immich_microservices
    image: ghcr.nju.edu.cn/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    # file: hwaccel.yml
    # service: hwaccel
    command: [ "start.sh", "microservices" ]
    volumes:
    - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
    - .env
    depends_on:
    - redis
    - database
    - typesense
    restart: always

    immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.nju.edu.cn/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
    - model-cache:/cache
    env_file:
    - .env
    restart: always

    immich-web:
    container_name: immich_web
    image: ghcr.nju.edu.cn/immich-app/immich-web:${IMMICH_VERSION:-release}
    env_file:
    - .env
    restart: always

    typesense:
    container_name: immich_typesense
    image: docker.nju.edu.cn/typesense/typesense:0.24.1@sha256:9bcff2b829f12074426ca044b56160ca9d777a0c488303469143dd9f8259d4dd
    environment:
    - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
    - TYPESENSE_DATA_DIR=/data
    # remove this to get debug messages
    - GLOG_minloglevel=1
    volumes:
    - tsdata:/data
    restart: always

    redis:
    container_name: immich_redis
    image: docker.nju.edu.cn/redis:6.2-alpine@sha256:70a7a5b641117670beae0d80658430853896b5ef269ccf00d1827427e3263fa3
    restart: always

    database:
    container_name: immich_postgres
    image: docker.nju.edu.cn/postgres:14-alpine@sha256:28407a9961e76f2d285dc6991e8e48893503cc3836a4755bbc2d40bcc272a441
    env_file:
    - .env
    environment:
    POSTGRES_PASSWORD: ${DB_PASSWORD}
    POSTGRES_USER: ${DB_USERNAME}
    POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
    - pgdata:/var/lib/postgresql/data
    restart: always

    immich-proxy:
    container_name: immich_proxy
    image: ghcr.nju.edu.cn/immich-app/immich-proxy:${IMMICH_VERSION:-release}
    environment:
    # Make sure these values get passed through from the env file
    - IMMICH_SERVER_URL
    - IMMICH_WEB_URL
    ports:
    - 5003:8080
    depends_on:
    - immich-server
    - immich-web
    restart: always

    volumes:
    pgdata:
    model-cache:
    tsdata:

.env不需要改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=./library

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secrets for postgres and typesense. You should change these to random passwords
TYPESENSE_API_KEY=some-random-text
DB_PASSWORD=postgres

# The values below this line do not need to be changed
###################################################################################
DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

REDIS_HOSTNAME=immich_redis

  1. 确认docker-compose.yml文件中immich-proxy段落里的ports端口没有问题,启动immich。

    1
    docker compose up -d
  2. 访问 http://{ip}:{port}

Notice: 正常情况下,这里会有一个基于utteranc.es的留言系统,如果看不到,可能需要科学上网方式。