Skip to content

πŸ“Έ Photos Server with Immich

immich_banner

Immich is an open-source high performance self-hosted photo and video backup solution. The backend is divided into several services, which are run as individual docker containers:

  • immich-server: handle and respond to REST API requests
  • immich-postgres: persistent data storage
  • immich-redis: queue management for immich-microservices

Info

The project is open-source and can be downloaded here: https://github.com/immich-app/immich.
The immich-machine-learning docker won't be installed.


πŸ“₯ Installation

πŸ“‹ Requirements

Info

Immich requires the installation of


🐳 Install Immich

The use of Docker Compose will automate the installation of immich container.

πŸ”§ Setup Immich Parameters

Before deploying, you need to define a few environment variables that will be used throughout the setup process.

  • HOST_PORT: external port used by NGINX to route traffic to the service
# example of configuration for environment parameters
HOST_PORT=10015
βš™οΈ Configure Immich for Docker Compose

Immich can be deployed using Docker Compose. The compose.yml file will automatically incorporate the environment variables configured in the previous step. You can copy, paste, and run all of the following commands directly in your terminal.

# create docker directory
mkdir immich && cd immich
mkdir data/immich data/postgres-db data/redis-db data/geocoding
# setup of compose.yml
tee compose.yml > /dev/null <<EOF
services:
  immich-server:
    image: ghcr.io/immich-app/immich-server:\${IMMICH_VERSION}
    container_name: immich-server
    user: "\${PUID}:\${PGID}"
    volumes:
      - ./data/immich:/usr/src/app/upload:rw
      - /etc/localtime:/etc/localtime:ro
    environment:
      - REDIS_HOSTNAME=immich-redis
      - DB_HOSTNAME=immich-postgres
      - DB_USERNAME=\${PG_USERNAME}
      - DB_PASSWORD=\${PG_PASSWORD}
      - MACHINE_LEARNING_MODEL_TTL_POLL_S=\${MACHINE_LEARNING_MODEL_TTL_POLL_S}
      - MACHINE_LEARNING_REQUEST_THREADS=\${MACHINE_LEARNING_REQUEST_THREADS}
    ports:
      - \${HOST_PORT}:2283
    depends_on:
      immich-redis:
        condition: service_healthy
      immich-postgres:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost:2283/"]
      start_period: 60s
      start_interval: 5s
      interval: 60s
      timeout: 1s
      retries: 3
    restart: unless-stopped

  immich-redis:
    image: docker.io/redis:6.2-alpine
    container_name: immich-redis
    user: "\${PUID}:\${PGID}"
    volumes:
      - ./data/redis-db:/data:rw
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      start_period: 30s
      start_interval: 5s
      interval: 60s
      timeout: 1s
      retries: 3
    restart: unless-stopped

  immich-postgres:
    image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0
    container_name: immich-postgres
    user: "\${PUID}:\${PGID}"
    volumes:
      - ./data/postgres-db:/var/lib/postgresql/data:rw
    environment:
      - POSTGRES_USER=\${PG_USERNAME}
      - POSTGRES_PASSWORD=\${PG_PASSWORD}
      - POSTGRES_INITDB_ARGS='--data-checksums'
    command: >-
      postgres
      -c shared_preload_libraries=vectors.so
      -c 'search_path="\$\$user", public, vectors'
      -c logging_collector=on
      -c max_wal_size=2GB
      -c shared_buffers=512MB
      -c wal_compression=on
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "\${PG_USERNAME}", "-d", "immich"]
      start_period: 60s
      start_interval: 5s
      interval: 60s
      timeout: 1s
      retries: 3
    restart: unless-stopped
EOF
# setup of .env file
tee .env > /dev/null <<EOF
###################################################################################
# Run as non-root user
###################################################################################
PUID=`id -u`
PGID=`id -g`

###################################################################################
# NGINX Proxy Configuration
###################################################################################
HOST_PORT=${HOST_PORT}

###################################################################################
# Postgres Database Configuration
###################################################################################
PG_USERNAME=immich
PG_PASSWORD=`openssl rand -hex 16`

###################################################################################
# Immich Configuration
###################################################################################
IMMICH_VERSION=release
MACHINE_LEARNING_MODEL_TTL_POLL_S=0
MACHINE_LEARNING_REQUEST_THREADS=0
EOF

Keep the .env file

All the secret informations will be stored in the .env file.

🐳 Install Immich with Docker Compose

Now that the compose.yml file has been generated, it's time to install all the containers.

# install and start the container
docker compose up -d

πŸš€ Deploy Immich

Install NGINX

NGINX needs to be installed, follow the NGINX section.

Configure NGINX

NGINX needs to be configured using a file in /etc/nginx/sites-available directory.
This configuration file specify the documentation path:

server {
  server_name immich.domain.fr;

  # setup 404 error_page
  error_page 404 /404.html;
  include snippets/error-404.conf;

  # reverse proxy
  location / {
    proxy_pass http://127.0.0.1:10015;

    # keep it HTTP/1.1 and enable WebSockets
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;

    # forwarded headers
    include proxy_params;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;

    # application-specific tuning
    proxy_read_timeout 600s;
    proxy_send_timeout 600s;
    client_max_body_size 500M;
  }
}
# enable site for production
sudo ln -s /etc/nginx/sites-available/immich.domain.fr /etc/nginx/sites-enabled/immich.domain.fr

# restart nginx
sudo nginx -t && sudo service nginx restart

Replace immich.domain.fr by the name of your website.

Activate HTTPS

To activate HTTPS protocol, follow theΒ Let's Encrypt section.


βš™οΈ Configure Immich

Register the Admin User

The first account created in the application automatically becomes the admin.
This admin account is responsible for creating and managing all other users.

To register the initial admin user, open the web interface at: https://immich.domain.fr

immich_registration