Everything was good, great in fact. Everything was working, but my OCD weren’t okay with how a few services were set-up, so I cleaned up my yaml, commented my docker compose and felt cushty… right up until it was time to fix Immich.

I have minor beef with Immich and basically any larger project and the way they go about their Docker Compose. Basically I feel they make the assumption that they’re the only thing running.

^Disclaimer: I fully accept this is all just me being too stupid and not the Immich development team.

So first things first, let’s rename database to immich-database, redis to immich-redis and most importantly, let’s give it a port that’s not the default postgres port that everyone wants to use. Easy right? Nope.

First Immich said it couldn’t find the database, so I went in and added the IP as the DB_URL to the .env. But that didn’t really help, so I went back to the Docker Compose and added the path to the references to the env.

Second issue I stumble upon, is that despite the port being available as DB_PORT Immich decided it was a suggestion and not an instruction. No worries, I edit the database URL to include the port.

Okay, I’m on the home stretch now right. I mean this was working before I decided to mess around with it in the name of scalability or whatever I thought was genius at the time… except

[Nest] 7  - 04/05/2024, 6:10:23 PM   ERROR [ExceptionHandler] no PostgreSQL user name specified in startup packet

What does that even mean? Why won’t you work? So I do a web search and everything is saying that docker probably isn’t reading the username from the env file or the Docker Compose. I try adding single quotes and no joy, double quotes, no joy. I have no idea where I’ve gone wrong. I feel like my beautiful simple Docker Compose now looks like Frankenstein’s Monster. Help 🙏

ENV

# 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=immichlibrary

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

# Connection secret for postgres. You should change it to a random password
DB_PASSWORD="RANDOMLIES"
DB_URL=http://192.168.0.89:8765
DB_PORT=8765

# 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

Docker Compose

version: "3.8"

#
# WARNING: Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.
#

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "immich" ]
    volumes:
      #- ${UPLOAD_LOCATION}:/usr/src/app/upload
      - immichlibrary:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - /opt/immich/.env
    environment:
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    ports:
      - 2283:3001
    depends_on:
      - immich-redis
      - immich-database
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.yml
    #   service: hwaccel
    command: [ "start.sh", "microservices" ]
    volumes:
      #- ${UPLOAD_LOCATION}:/usr/src/app/upload
      - immichlibrary:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - /opt/immich/.env
    environment:
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    depends_on:
      - immich-redis
      - immich-database
    restart: always

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

  immich-redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:c5a607fb6e1bb15d32bbcf14db22787d19e428d59e31a5da67511b49bb0f1ccc
    restart: always

  immich-database:
    container_name: immich_postgres
    image: tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    env_file:
      - /opt/immich/.env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    ports:
      - 8765:5432
    volumes:
      - /opt/immich/postgres:/var/lib/postgresql/data
    restart: always

volumes:
  model-cache:
    driver_opts:
      type: "nfs"
      o: "addr=192.168.0.245,nolock,soft,rw"
      device: ":/mnt/Shared Pictures/.Immich/cache"
  immichlibrary:
    driver_opts:
      type: "nfs"
      o: "addr=192.168.0.245,nolock,soft,rw"
      device: ":/mnt/Shared Pictures/.Immich"

Even if you read this and don’t feel you can help or have nothing to add, thanks for sharing your time with me 🥹

  • lemmyvore
    link
    fedilink
    English
    23 months ago

    When you rename a service it helps to figure out why you’re doing it, because there’s different ways in which they relate to each other. There’s usually no point in renaming the services because they’re only used inside the compose for dependencies. You can rename the containers names but you have to be careful because if you don’t specify hostnames explicitly it uses the contain name and the services won’t find each other anymore.

    I believe Immich ignores those env vars that specify the db and redis hostnames so don’t mess with that.

    • @sabreW4K3OP
      link
      English
      13 months ago

      Thank you very much. I had one eye on combining all my compose files in the future to make things more remotely manageable and that’s probably been my folly here.

      • lemmyvore
        link
        fedilink
        English
        23 months ago

        It’s good to want to have that but dumping everything in one compose file is not the way. Read through the compose docs, there are many things you can use to achieve modularity. Start with fragments then continue with the next sections (extensions, interpolation, merge, include and profiles).

        If you want to do things with networking you can, there’s a ton of things you can do to make containers connect in all kinds of networks, you can control IPs, you can control MACs, you can make containers show up as regular machines on your LAN and take their IP from DHCP and have names in DNS etc.

        The only reason to put things in the same compose file is as a convenience when you have a set of containers that are strongly related and make up a single “app” between them, but some applications go overboard with complexity. Immich is merely mildly annoying, have a look at mailcow for comparison, now that’s bad.

        • @sabreW4K3OP
          link
          English
          13 months ago

          I’m not going to lie to you, clicking that second link was overwhelming, but that first link… that made me grin like a child that just got a bag of sweets. Thank you!

          • lemmyvore
            link
            fedilink
            English
            23 months ago

            It’s worth reading through all the docker docs sometime, it can do a lot of cool stuff. I’ll leave these here:

            The mailcow compose is actually worth coming back to when you’ve had some more experience. There are a ton of interesting tricks in there like overriding the DNS server, defining fallback values for env vars, sharing/unsharing volumes between containers with the :z and :Z flags, [ab]using the command to perform initializations or to wait for another container etc.