User Tools

This is an old revision of the document!


Immich

Immich is a modern photo management web application which aims to be similar to Google Photo. It can be uses to backup phone photos and also manage older collection of older photos.

Immich come along a long way in the past year, and even if i had initially tried it out but abandoned due to the lack of some basic (for my use case) features, i can say that as little as less than one year later it proved not only to be the one top photo management backup and gallery solution for self-hosting, but a damn good one too. The devs really rocks and work hard, and Immich itself is so flexible that there are little excuses not to use it!

Immich, at this time, still does not support base_url out of the box. A lot of discussion is going on around the topic and somebody found a nice fix using a specific NGINX setup, but i think it's better to stick to subdomains for Immich, at least until it will officially support sub-paths. Anyway, you should really use subdomains with something so complex as Immich to leverage cross-domain security.

While installing Immich overall is not a huge task, you should really read carefully this page and all the very good documentation on Immich website itself.

Installation

I will assume you will store all Immich stuff under /data/photos. You will need two folders here:

  • /data/photos/Library: will contain your photos and all additional Immich files (cache, thumbnails, encoded videos…). You want to backup the library (yes, lowercase!) and backups subfolders in here.
  • /data/photos/immich_database: will contain PostgreSQL stuff, you do not want to backup this folder.

Immich needs to be installed using a docker compose file. This is the official and only supported installation method. I will show you, of course, how to run it rootless with podman. Immich installation is detailed here, and i suggest you take a look at.

I assume you have already created the photo user and group (see here, but in case you didn't, here you go:

useradd -d /data/daemons/photos photos
mkdir /data/photos
mkdir /data/photos/Library
mkdir /data/photos/immich_database

And download the standard Immich docker-compose and env files:

su - photos
wget https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#optional: wget https://github.com/immich-app/immich/releases/latest/download/hwaccel.transcoding.yml
#optional: wget https://github.com/immich-app/immich/releases/latest/download/hwaccel.ml.yml
wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env

(enabling hardware acceleration is optional and i will not cover it here, as it's not needed in my use-case)

I will not give you a full docker-compose file, because Immich sometimes ships with backward incompatibilities, you must start from the one linked above and do the following modifications:

  • Specify a network to all containers
  • Add any specific volumes for specific external galleries
  • Remove the restart and healthcheck sections

This is the specific code for the network:

# Add these two lines to each one of the services (immich-server, immich-microservices, immich-machine-learning, redis, database, ...)
    networks:
      - immich-net

# This goes at the end of the file:
networks:
  immich-net: {}

Please note that you can have more than one mount, ideally one for each folder tree that contains photos you want to add as external library to Immich.

edit the /data/daemons/immich/.env file to adapt at least your Uploads and external folder:

# The location where your uploaded files are stored
UPLOAD_LOCATION=/data/photos/Library
# The location where your database files are stored
DB_DATA_LOCATION=/data/photos/immich_database

You can fine-tune the rest of the env file to your needs.

Configuration

You should follow all the steps below before starting using Immich for real, as they have some implications and it's better to sort out stuff before, than reorganize everything later. Immich does a pretty great job of ensuring it's consistent and changeable at a later point in time tough. Still better to dedicate a little time to think stuff out before than later.

External Library setup

External libraries let you integrate into Immich existing and already sorted out image libraries. It's a very welcome feature that let's you use Immich in evary conceivable scenario.

This page will give you more details on how to set up an external library.

You have to perform two steps:

  • Add the external library path as a volume in docker compose
  • From Immich web GUI, create the external library pointing to that path

So, in your docker-compose.yml ensure that you have mapped each external library like this example:

services:
  immich-server:
    volumes:
      - /data/photos/ExistingGallery:/mnt/media/ExistingGallery:ro

Then, you have to go to Immich web gui → administration → external libraries and add create a new library. Each library must belong to an user and shall have one or more paths, the ones mapped as above, inside.

You can also setup a watcher to monitor for new files or period scans to ensure new added files get updated inside Immich as well.

Keep in mind that Immich will not touch the files inthe external library at all, which means that any change to those files metadata will not be embedded in the external library files.

Storage Template setup

Storage templates let's you choose how Immich should store photos and videos on your filesystem. This is specially useful if you like to sort your photos for albums and/or year-month-day. I think this is a very powerful feature of Immich and a very welcome addition to it's features.

My template is:

{{y}}/{{#if album}}{{album}}{{else}}Others{{/if}}/{{filename}}

this template will store folders by year and album. If the photo is not stored in an album, it will go into a folder called Others.

That can be setup from Immich web gui → administration → settings → storage templates.

You also need to enable it from the same setting area. Remember to run the update storage templates task if you change it. Also, remember to check that it's working as intended before you have thousand of photos stored the wrong way.

SSO authentication setup

Immich support direct integration with Authelia SSO, specific instructions can be found on this page.

First of all, you need to configure Authelia with a new client:

identity_providers:
  oidc:
    ## The other portions of the mandatory OpenID Connect 1.0 configuration go here.
    ## See: https://www.authelia.com/c/oidc
    clients:
      - client_id: << see below to generate ClientID >>
        client_name: 'immich'
        client_secret: << see below to generale ClientSecret >>
        public: false
        authorization_policy: 'one_factor'
        redirect_uris:
          - 'https://immich.mydomain.com/auth/login'
          - 'https://immich.mydomain.com/user-settings'
          - 'app.immich:///oauth-callback'
        scopes:
          - 'openid'
          - 'profile'
          - 'email'
        userinfo_signed_response_alg: 'none'

To generate a ClientID:

authelia crypto rand --length 72 --charset rfc3986

This information will need to copied to both authelia config and immich settings.

To generate a Client Secret:

authelia crypto hash generate pbkdf2 --variant sha512 --random --random.length 72 --random.charset rfc3986

Please note both the hash and the password itself! You will need the password itself in the next step.

Then you need to configure Immich to use Authelia SSO, so go to Immich web gui → administration → settings → Authentication settings and enter the following information:

Bakcup setup

I assume you have setup a backup schedule like described here, with restic.

For Immich you should backup:

  • /data/photos/Library/library: where actual photos are stored
  • /data/photos/Library/backups: where postgres backups are stored

You should also go to Immich web gui → administration → settings → backups and reduce the retain to 1 or 2 backups, since you will be backing them up with restic.

NGINX reverse proxy

Immich officially only support subdomain and not subpath deployment. Use the following NGINX configuration, i will assume your subdomain is called immich.mydomain.com. See here for more details.

immich.conf
 
    server {
        server_name immich.mydomain.com;
        listen 8443 ssl; 
        listen 443 ssl; 
        client_max_body_size 5000M;
        large_client_header_buffers 4 32k;

        access_log /var/log/nginx/immich.mydomain.com_access_log main;
        error_log /var/log/nginx/immich.mydomain.com_error_log info;

        location / {
        location / {
                proxy_pass http://127.0.0.1:2283;
                #proxy_pass http://127.0.0.1:8009;
                proxy_redirect    default;
                proxy_set_header  Host $host;
                proxy_set_header  X-Real-IP $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header  X-Forwarded-Host $server_name;
                proxy_set_header  X-Forwarded-Proto $scheme;
        }
        include com.mydomain/certbot.conf;
}

Autostart

To start it, and set it up on boot, as usual follow my indications Using Containers on Gentoo, so link the user-containers init script:

ln -s /etc/init.d/user-containers /etc/init.d/user-containers.immich

and create the following config file:

/etc/conf.d/user-containers.immich
USER=immich
DESCRIPTION="The photo gallery and backup solution"

Add the service to the default runlevel and start it now:

rc-update add user-containers.immich default
rc-service user-containers.immich start

Command line CLI

Immich has a CLI which requires NPM:

emerge nodejs

as user immich:

npm i -g @immich/cli

The CLI might require login for upload operations:

immich login-key https://10.0.0.1/immich/api [apiKey]
immich upload --recursive directory/

Update

When you want to update Immich, just:

su - immich
podman compose down
podman compose pull
podman compose up -d

Be aware that Immich is bleeding edge and sometimes there are breaking updates! Always check on Immich Releases page the release notes and take actions accordingly. YOU HAVE BEEN WARNED.

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information