Immich on TrueNAS CORE

Joined
Nov 2, 2023
Messages
4
I wanted to get Immich working on my TrueNAS system but saw there was no official support for it on FreeBSD and found no guides from others trying to do it. I think there's an interest, so I'll describe here the steps I took to get it to work and hopefully that'll help others do the same. For those a lot smarter than me, please feel free to suggest improvements or just comment where I did something wrong.

Immich is a self-hosted backup solution for photos and videos with mobile device support. The recommended way to install it is with docker and that would run in several containers. Why not get them to work in a jail on TrueNAS CORE instead. They break it out into 8 containers, only two of them I couldn't get to work since (as far as I know) they are not supported on FreeBSD. Immich can still work without the machine learning and typesense, just some features won't work.
nameusesgot working with
immich_servernodenode 18
immich_microservicesnodenode 18
immich_machine_learningpytorch2.0not supported on FreeBSD
immich_webnodenode 18
immich_typesensetypesensenot supported on FreeBSD
immich_redisredisredis 7
immich_postgrespostgrespostgresql 14
immich_proxynginxnginx 1.24

First Steps:​

  1. Create Jail, I'm using release 13.2 with DHCP auto-configured
  2. I'm mounting a dataset to the jail in the location: /mnt/data
  3. install packages: node18, npm-node18, nginx, graphics/vips, multimedia/ffmpeg, git, postgresql14-server, postgresql14-contrib, redis
  4. create immich user in the wheel group: adduser
  5. chown immich:wheel /mnt/data
  6. enable services in /etc/rc.conf
    • nginx_enable="YES"
    • redis_enable="YES"
    • postgresql_enable="YES"
  7. configure postgresql, run these commands
    1. /usr/local/etc/rc.d/postgresql initdb
    2. service postgresql start
    3. passwd postgres
      • need this pw later
      • using "postgres" for this example
    4. su - postgres
    5. createuser postgres
    6. createdb immich -O postgres
    7. (any other configurations you want)
    8. serice postgresql restart
  8. start redis: service redis start

Install Immich​

  1. clone immich, git clone https://github.com/immich-app/immich
  2. checkout desired release version, using 1.84.0 here

build server/microservices​

  1. navigate to server dir in the immich git repo
  2. npm ci
  3. npm run build
  4. npm prune --omit=dev --omit=optional
  5. mkdir /usr/local/www/immich/server
  6. cp -R ./ /usr/local/www/immich/server
  7. chown -R immich:wheel /usr/local/www/immich
  8. mkdir /usr/local/etc/immich
  9. strip these files (strip command)
    • /usr/local/www/immich/server/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node
    • /usr/local/www/immich/server/node_modules/bcrypt/build-tmp-napi-v3/Release/obj.target/bcrypt_lib.node
    • /usr/local/www/immich/server/node_modules/bcrypt/build-tmp-napi-v3/Release/bcrypt_lib.node
    • /usr/local/www/immich/server/node_modules/sharp/build/Release/obj.target/sharp-freebsd-x64.node
    • /usr/local/www/immich/server/node_modules/sharp/build/Release/sharp-freebsd-x64.node
  10. change these files with sed
    • sed -i '' -e "1s|/bin/bash|/usr/local/bin/bash|" /usr/local/www/immich/server/node_modules/fluent-ffmpeg/tools/test-travis.sh
    • sed -i '' -e "1s|/usr/bin/perl|/usr/local/bin/perl|" /usr/local/www/immich/server/node_modules/exiftool-vendored.pl/bin/validate
    • sed -i '' -e "1s|/usr/bin/perl|/usr/local/bin/perl|" /usr/local/www/immich/server/node_modules/exiftool-vendored.pl/bin/build_tag_lookup
    • sed -i '' -e "1s|/usr/bin/perl|/usr/local/bin/perl|" /usr/local/www/immich/server/node_modules/exiftool-vendored.pl/bin/exiftool
  11. create immich_microservices service script in /usr/local/etc/rc.d (make sure it's executable)
    Code:
    #!/bin/sh
    #
    # $FreeBSD$
    #
    # PROVIDE: immich_microservices
    # REQUIRE: NETWORKING DAEMON postgres
    # KEYWORD: shutdown
    #
    # Add the following lines to /etc/rc.conf:
    #
    #immich_microservices_enable="YES"
    . /etc/rc.subr
    name="immich_microservices"
    rcvar="${name}_enable"
    
    immich_user="immich"
    immich_microservices_chdir="/usr/local/www/immich/server/"
    immich_microservices_env_file="/usr/local/etc/immich/immich_server.env"
    immich_microservices_env="NODE_ENV=production"
    pidfile="/var/run/${name}.pid"
    procname="/usr/local/bin/node"
    
    node="/usr/local/bin/node"
    node_arg="dist/main microservices"
    
    command="/usr/sbin/daemon"
    command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"
    
    load_rc_config ${name}
    run_rc_command "$1"
  12. create immich_server service script in /usr/local/etc/rc.d (make sure it's executable)
    Code:
    #!/bin/sh
    #
    # $FreeBSD$
    #
    # PROVIDE: immich_server
    # REQUIRE: NETWORKING DAEMON postgres redis
    # KEYWORD: shutdown
    #
    # Add the following lines to /etc/rc.conf:
    #
    #immich_server_enable="YES"
    . /etc/rc.subr
    name="immich_server"
    rcvar="${name}_enable"
    
    immich_user="immich"
    immich_server_chdir="/usr/local/www/immich/server/"
    immich_server_env_file="/usr/local/etc/immich/immich_server.env"
    immich_server_env="NODE_ENV=production"
    pidfile="/var/run/$name.pid"
    procname="/usr/local/bin/node"
    
    node="/usr/local/bin/node"
    node_arg="dist/main immich"
    
    command="/usr/sbin/daemon"
    command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"
    
    load_rc_config ${name}
    run_rc_command "$1"
  13. create immich_server.env in /usr/local/etc/immich
    Code:
    # 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_ENABLED=false
    
    DB_HOSTNAME=localhost
    DB_USERNAME=postgres
    DB_DATABASE_NAME=immich
    DB_PASSWORD=postgres
    
    REDIS_HOSTNAME=localhost
    
    # Path where Immich will store its assets
    IMMICH_MEDIA_LOCATION="/mnt/data"
    

build web​

  1. navigate to web dir in the immich git repo
  2. npm ci
  3. npm run build
  4. npm prune --omit=dev
  5. mkdir /usr/local/www/immich/web
  6. cp -R ./ /usr/local/www/immich/web
  7. chown -R immich:wheel /usr/local/www/immich
  8. create immich_web service script in /usr/local/etc/rc.d (make sure it's executable)
    Code:
    #!/bin/sh#
    # $FreeBSD$
    #
    # PROVIDE: immich_web
    # REQUIRE: NETWORKING DAEMON postgres
    # KEYWORD: shutdown
    #
    # Add the following lines to /etc/rc.conf:
    #
    #immich_web_enable="YES"
    . /etc/rc.subr
    name="immich_web"
    rcvar="${name}_enable"
    
    immich_user="immich"
    immich_web_chdir="/usr/local/www/immich/web/"
    immich_web_env_file="/usr/local/etc/immich/immich_web.env"
    immich_web_env="NODE_ENV=production"
    pidfile="/var/run/${name}.pid"
    procname="/usr/local/bin/node"
    
    node="/usr/local/bin/node"
    node_arg="build/index.js"
    
    command="/usr/sbin/daemon"
    command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"
    
    load_rc_config ${name}
    run_rc_command "$1"
  9. create immich_web.env in /usr/local/etc/immich
    Code:
    # You can find documentation for all the supported env variables at https://imm>
    # Port where the web application will listen. Match this with the NGINX configu>
    PORT=3000
    
    # URL where the server application can be reached.
    IMMICH_SERVER_URL=http://localhost:3001
    PUBLIC_IMMICH_SERVER_URL=http://localhost:3001
    
  10. create a immich.conf in /usr/local/www/nginx
    Code:
    server {  
      server_name localhost;
      listen 80;
    
      access_log off;
      client_max_body_size 50000M;
    
      # Compression
      gzip off;
      gzip_comp_level 2;
      gzip_min_length 1000;
      gzip_proxied any;
      gzip_vary on;
      gunzip on;
    
      # text/html is included by default
      gzip_types
        application/javascript
        application/json
        font/ttf
        image/svg+xml
        text/css;
    
      location /api {
        proxy_buffering off;
        proxy_buffer_size 16k;
        proxy_busy_buffers_size 24k;
        proxy_buffers 64 4k;
        proxy_force_ranges on;
    
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
    
        rewrite /api/(.*) /$1 break;
        proxy_pass "http://localhost:3001/";
      }
    
      location / {
        proxy_buffering off;
        proxy_buffer_size 16k;
        proxy_busy_buffers_size 24k;
        proxy_buffers 64 4k;
        proxy_force_ranges on;
    
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
    
        proxy_pass "http://localhost:3000/";
      }
    }
  11. include that conf under the http tag in the nginx conf (probably want to remove the template servers in that file too)
  12. check the nginx config with, nginx -t
  13. service nginx start
  14. service immich_microservices start
  15. service immich_server start
  16. service immich_web start
And hopefully that does it for you. You should be able to go in your browser to your jail's ip address and immich will be there. You can check in /var/log/debug.log to see some logs. I'm running typesense elsewhere to get the search functionality to work. Just need to add to the immich_server.env, like the host name. Environment variables can be seen here: https://immich.app/docs/install/environment-variables. I haven't tried getting the machine learning to work, but maybe someone else will have luck doing that.

Hope this helps! (and hope I didn't miss anything)
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
Hi @countithigher .. I just wanted to thank you for doing this! I know it was a lot of work and I tried implementing it last night and there were a few minor issues with a few things that needed minor tweaks but nothing difficult to figure out.

However, the sticking point is with starting things up. For some reason I can't get things running on localhost:3001 -- I'm not sure what should be running there off the top of my head (the web app I believe -- or part of it) but when I fire up the browser on http://192.168.1.248:3000 for my jail, I get a connection refused error as shown in the attached image.

A sockstat -l shows nothing running on port 3001.

Code:
# sockstat -l
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
immich   node       87247 16 tcp4   192.168.1.248:3000    *:*
www      nginx      85832 6  tcp4   192.168.1.248:80      *:*
root     nginx      85807 6  tcp4   192.168.1.248:80      *:*
redis    redis-serv 74313 7  tcp4   192.168.1.248:6379    *:*
postgres postgres   55728 6  tcp4   192.168.1.248:5432    *:*
postgres postgres   55728 7  stream /tmp/.s.PGSQL.5432
root     sendmail   47424 5  tcp4   192.168.1.248:25      *:*
root     syslogd    42543 5  udp4   192.168.1.248:514     *:*
root     syslogd    42543 6  dgram  /var/run/log
root     syslogd    42543 7  dgram  /var/run/logpriv



I believe that nginx is working as a reverse proxy in large part and also serving up the immich pages -- but I've personally got Caddy running on the same system doing that role for some other self-hosted software .. Anyway, if you've got suggestions for debugging this stuff.. I know I'm at the 95% mark -- but something isn't happy for some reason or another..

I'll dig into it tonight after work as time permits.. Thanks again!
 

Attachments

  • capture-opas901a.jpg
    capture-opas901a.jpg
    81.6 KB · Views: 120
Joined
Nov 2, 2023
Messages
4
Hi @ps23Rick, glad it helped!

You should be able to just go to localhost:80 and the nginx config will direct from there. Your sockstat leads me to believe your immich_server service isn't running, can you check the status of that service (service immich_server status)?

When I was working out some issues, I found some help in /var/log/debug.log. After you try to start the service, just check with tail on the log. Could be as simple as file/folder permissions
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
thanks for your reply @countithigher ... You are correct.. my immich_server is not running.. and can't as there are a few issues and once I start it, it barfs and shuts down after a few minutes -- here are the highlights that I need to resolve (taken from /var/log/debug.log):

Code:
Nov 14 12:57:21 homegallery immich_server[87911]: ReplyError: DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Set up an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.


and later...

Code:
Nov 14 12:57:15 homegallery immich_server[87911]: error: no pg_hba.conf entry for host "192.168.1.248", user "postgres", database "immich", no encryption
Nov 14 12:57:15 homegallery immich_server[87911]:     at Parser.parseErrorMessage (/usr/local/www/immich/server/node_modules/pg-protocol/dist/parser.js:287:98)
Nov 14 12:57:15 homegallery immich_server[87911]:     at Parser.handlePacket (/usr/local/www/immich/server/node_modules/pg-protocol/dist/parser.js:126:29)
Nov 14 12:57:15 homegallery immich_server[87911]:     at Parser.parse (/usr/local/www/immich/server/node_modules/pg-protocol/dist/parser.js:39:38)
Nov 14 12:57:15 homegallery immich_server[87911]:     at Socket.<anonymous> (/usr/local/www/immich/server/node_modules/pg-protocol/dist/index.js:11:42)
Nov 14 12:57:15 homegallery immich_server[87911]:     at Socket.emit (node:events:517:28)
Nov 14 12:57:15 homegallery immich_server[87911]:     at addChunk (node:internal/streams/readable:335:12)
Nov 14 12:57:15 homegallery immich_server[87911]:     at readableAddChunk (node:internal/streams/readable:308:9)
Nov 14 12:57:15 homegallery immich_server[87911]:     at Readable.push (node:internal/streams/readable:245:10)
Nov 14 12:57:15 homegallery immich_server[87911]:     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)


I'll take a look at these when I get home tonight after work.. at least I can go from here and see what needs adjusting..
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
Ok.. So I fixed a few things .. fixed the Postgres config so it would work properly .. and disabled the redis protected mode and also had to fix the /mnt/data path to point to a valid directory in my particular case. Once I restarted Postgres, redis and finally started immich_server then things came up and I got the opening screen on the webpage. :smile:

But I'm stuck at the admin registration page ... If I click on the sign-up button, I get errors in the log for immich_web :

Code:
Nov 14 19:35:19 homegallery immich_web[87069]: [hooks.server.ts]:handleError Not found: /api/socket.io/
Nov 14 19:35:54 homegallery syslogd: last message repeated 7 times
Nov 14 19:36:29 homegallery syslogd: last message repeated 7 times
Nov 14 19:36:29 homegallery immich_web[87069]: [hooks.server.ts]:handleError Not found: /api/server-info/features
Nov 14 19:36:29 homegallery immich_web[87069]: [hooks.server.ts]:handleError Not found: /api/server-info/config
Nov 14 19:36:30 homegallery immich_web[87069]: [hooks.server.ts]:handleError Not found: /api/socket.io/
Nov 14 19:36:37 homegallery syslogd: last message repeated 2 times
Nov 14 19:37:52 homegallery immich_web[87069]: [hooks.server.ts]:handleError Not found: /api/auth/admin-sign-up
Nov 14 19:38:07 homegallery syslogd: last message repeated 1 times


I think those "not found" are associated with the Sveltekit stuff.. thoughts on how to proceed would be great. I'm sort of thinking something might not be running -- one (or more) of the micro services.

Thanks for any insight...
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
this is what my sockets look like for reference if this might be helpful :

Code:
root@homegallery:/usr/local/etc/immich # sockstat -l
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
immich   node       91547 31 tcp4   192.168.1.248:3001    *:*
redis    redis-serv 88846 7  tcp4   192.168.1.248:6379    *:*
postgres postgres   74076 6  tcp4   192.168.1.248:5432    *:*
postgres postgres   74076 7  stream /tmp/.s.PGSQL.5432
immich   node       87247 16 tcp4   192.168.1.248:3000    *:*
www      nginx      85832 6  tcp4   192.168.1.248:80      *:*
root     nginx      85807 6  tcp4   192.168.1.248:80      *:*
root     sendmail   47424 5  tcp4   192.168.1.248:25      *:*
root     syslogd    42543 5  udp4   192.168.1.248:514     *:*
root     syslogd    42543 6  dgram  /var/run/log
root     syslogd    42543 7  dgram  /var/run/logpriv
 
Joined
Nov 2, 2023
Messages
4
Are you trying to connect to it through nginx or just on port 3000? the nginx config finds location /api and maps it to the server part on port 3001. going straight to the app on port 3000 shouldn't work, i believe. If that's not it, can you post your nginx config, immich_web.env, and immich_server.env? maybe something isn't right in one of those.
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
Ok.. you were right… I just needed to connect on 192.168.1.248:80 (without the port) .. instead of connecting on port 3000 (or was it 3001).. In connecting just to port 80 it got me signed up just fine and I was able to login afterwards. I think I was thrown off by all the interconnects with immich as it’s not a single monolithic “app” like many are — but has a lot of services and so forth (aka plumbing) to confuse things if someone isn’t familiar.. Anyway, I think I’m set at this point.

ps. For others that might stumble across this thread wanting to get immich up and running, this set of instructions goes for FreeBSD aside from TrueNas as well. The system I just got this running on is FreeBSD 13.2 (not a TrueNas installation). Perhaps at some point I’ll switch to TrueNas but for now…

Thank you again @countithigher for your excellent write-up and assistance with getting some kinks worked out on my end! Your hard work is greatly appreciated!
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
Ok.. I guess I shouldn’t have spoken too soon.. I’ve got an authentication error in the server showing up after uploading some photos.. I’ll have to look into that later I guess.. below is what I found in my debug log (/var/log/debug.log) just now :

Code:
Nov 15 07:38:08 homegallery immich_server[91370]: ^[[32m[Nest] 91547  - ^[[39m11/15/2023, 7:38:08 AM ^[[32m    LOG^[[39m ^[[38;5;3m[CommunicationRepository] ^[[39m^[[32mWebsocket Connect:    PRj68GjFp88Eh7KuAAAB^[[39m
Nov 15 07:38:08 homegallery immich_server[91370]: ^[[31m[Nest] 91547  - ^[[39m11/15/2023, 7:38:08 AM ^[[31m  ERROR^[[39m ^[[38;5;3m[CommunicationRepository] ^[[39m^[[31mWebsocket connection error: UnauthorizedException: Authentication required^[[39m
Nov 15 07:38:08 homegallery immich_server[91370]: UnauthorizedException: Authentication required
Nov 15 07:38:08 homegallery immich_server[91370]:     at AuthService.validate (/usr/local/www/immich/server/dist/domain/auth/auth.service.js:112:15)
Nov 15 07:38:08 homegallery immich_server[91370]:     at CommunicationRepository.handleConnection (/usr/local/www/immich/server/dist/infra/repositories/communication.repository.js:30:49)
Nov 15 07:38:08 homegallery immich_server[91370]:     at Object.next (/usr/local/www/immich/server/node_modules/@nestjs/websockets/web-sockets-controller.js:77:47)
Nov 15 07:38:08 homegallery immich_server[91370]:     at ConsumerObserver.next (/usr/local/www/immich/server/node_modules/rxjs/dist/cjs/internal/Subscriber.js:113:33)
Nov 15 07:38:08 homegallery immich_server[91370]:     at Subscriber._next (/usr/local/www/immich/server/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:26)
Nov 15 07:38:08 homegallery immich_server[91370]:     at Subscriber.next (/usr/local/www/immich/server/node_modules/rxjs/dist/cjs/internal/Subscriber.js:51:18)
Nov 15 07:38:08 homegallery immich_server[91370]:     at /usr/local/www/immich/server/node_modules/rxjs/dist/cjs/internal/operators/distinctUntilChanged.js:18:28
Nov 15 07:38:08 homegallery immich_server[91370]:     at OperatorSubscriber._this._next (/usr/local/www/immich/server/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:33:21)
Nov 15 07:38:08 homegallery immich_server[91370]:     at Subscriber.next (/usr/local/www/immich/server/node_modules/rxjs/dist/cjs/internal/Subscriber.js:51:18)
Nov 15 07:38:08 homegallery immich_server[91370]:     at /usr/local/www/immich/server/node_modules/rxjs/dist/cjs/internal/Subject.js:69:34


I got that after selecting a few images to upload — they’re currently sitting in the upload folder waiting to be processed.. I’ll look it over when I get home for work later today.. Doh!
 
Joined
Nov 2, 2023
Messages
4
make sure your files and folders belong to immich:wheel, like IMMICH_MEDIA_LOCATION
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
@countithigher ... I figured it out.. my microservices was not running... Doh! Now after restarting the web and server pieces and starting microservices, the images stuck in limbo from the other day are now showing up in the timeline just fine! I just upload another image and all is well! Thanks for the help!!
 
Last edited:

riotbob

Cadet
Joined
Nov 7, 2023
Messages
4
I wanted to get Immich working on my TrueNAS system but saw there was no official support for it on FreeBSD and found no guides from others trying to do it. I think there's an interest, so I'll describe here the steps I took to get it to work and hopefully that'll help others do the same. For those a lot smarter than me, please feel free to suggest improvements or just comment where I did something wrong.

Immich is a self-hosted backup solution for photos and videos with mobile device support. The recommended way to install it is with docker and that would run in several containers. Why not get them to work in a jail on TrueNAS CORE instead. They break it out into 8 containers, only two of them I couldn't get to work since (as far as I know) they are not supported on FreeBSD. Immich can still work without the machine learning and typesense, just some features won't work.
nameusesgot working with
immich_servernodenode 18
immich_microservicesnodenode 18
immich_machine_learningpytorch2.0not supported on FreeBSD
immich_webnodenode 18
immich_typesensetypesensenot supported on FreeBSD
immich_redisredisredis 7
immich_postgrespostgrespostgresql 14
immich_proxynginxnginx 1.24

First Steps:​

  1. Create Jail, I'm using release 13.2 with DHCP auto-configured
  2. I'm mounting a dataset to the jail in the location: /mnt/data
  3. install packages: node18, npm-node18, nginx, graphics/vips, multimedia/ffmpeg, git, postgresql14-server, postgresql14-contrib, redis
  4. create immich user in the wheel group: adduser
  5. chown immich:wheel /mnt/data
  6. enable services in /etc/rc.conf
    • nginx_enable="YES"
    • redis_enable="YES"
    • postgresql_enable="YES"
  7. configure postgresql, run these commands
    1. /usr/local/etc/rc.d/postgresql initdb
    2. service postgresql start
    3. passwd postgres
      • need this pw later
      • using "postgres" for this example
    4. su - postgres
    5. createuser postgres
    6. createdb immich -O postgres
    7. (any other configurations you want)
    8. serice postgresql restart
  8. start redis: service redis start

Install Immich​

  1. clone immich, git clone https://github.com/immich-app/immich
  2. checkout desired release version, using 1.84.0 here

build server/microservices​

  1. navigate to server dir in the immich git repo
  2. npm ci
  3. npm run build
  4. npm prune --omit=dev --omit=optional
  5. mkdir /usr/local/www/immich/server
  6. cp -R ./ /usr/local/www/immich/server
  7. chown -R immich:wheel /usr/local/www/immich
  8. mkdir /usr/local/etc/immich
  9. strip these files (strip command)
    • /usr/local/www/immich/server/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node
    • /usr/local/www/immich/server/node_modules/bcrypt/build-tmp-napi-v3/Release/obj.target/bcrypt_lib.node
    • /usr/local/www/immich/server/node_modules/bcrypt/build-tmp-napi-v3/Release/bcrypt_lib.node
    • /usr/local/www/immich/server/node_modules/sharp/build/Release/obj.target/sharp-freebsd-x64.node
    • /usr/local/www/immich/server/node_modules/sharp/build/Release/sharp-freebsd-x64.node
  10. change these files with sed
    • sed -i '' -e "1s|/bin/bash|/usr/local/bin/bash|" /usr/local/www/immich/server/node_modules/fluent-ffmpeg/tools/test-travis.sh
    • sed -i '' -e "1s|/usr/bin/perl|/usr/local/bin/perl|" /usr/local/www/immich/server/node_modules/exiftool-vendored.pl/bin/validate
    • sed -i '' -e "1s|/usr/bin/perl|/usr/local/bin/perl|" /usr/local/www/immich/server/node_modules/exiftool-vendored.pl/bin/build_tag_lookup
    • sed -i '' -e "1s|/usr/bin/perl|/usr/local/bin/perl|" /usr/local/www/immich/server/node_modules/exiftool-vendored.pl/bin/exiftool
  11. create immich_microservices service script in /usr/local/etc/rc.d (make sure it's executable)
    Code:
    #!/bin/sh
    #
    # $FreeBSD$
    #
    # PROVIDE: immich_microservices
    # REQUIRE: NETWORKING DAEMON postgres
    # KEYWORD: shutdown
    #
    # Add the following lines to /etc/rc.conf:
    #
    #immich_microservices_enable="YES"
    . /etc/rc.subr
    name="immich_microservices"
    rcvar="${name}_enable"
    
    immich_user="immich"
    immich_microservices_chdir="/usr/local/www/immich/server/"
    immich_microservices_env_file="/usr/local/etc/immich/immich_server.env"
    immich_microservices_env="NODE_ENV=production"
    pidfile="/var/run/${name}.pid"
    procname="/usr/local/bin/node"
    
    node="/usr/local/bin/node"
    node_arg="dist/main microservices"
    
    command="/usr/sbin/daemon"
    command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"
    
    load_rc_config ${name}
    run_rc_command "$1"
  12. create immich_server service script in /usr/local/etc/rc.d (make sure it's executable)
    Code:
    #!/bin/sh
    #
    # $FreeBSD$
    #
    # PROVIDE: immich_server
    # REQUIRE: NETWORKING DAEMON postgres redis
    # KEYWORD: shutdown
    #
    # Add the following lines to /etc/rc.conf:
    #
    #immich_server_enable="YES"
    . /etc/rc.subr
    name="immich_server"
    rcvar="${name}_enable"
    
    immich_user="immich"
    immich_server_chdir="/usr/local/www/immich/server/"
    immich_server_env_file="/usr/local/etc/immich/immich_server.env"
    immich_server_env="NODE_ENV=production"
    pidfile="/var/run/$name.pid"
    procname="/usr/local/bin/node"
    
    node="/usr/local/bin/node"
    node_arg="dist/main immich"
    
    command="/usr/sbin/daemon"
    command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"
    
    load_rc_config ${name}
    run_rc_command "$1"
  13. create immich_server.env in /usr/local/etc/immich
    Code:
    # 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_ENABLED=false
    
    DB_HOSTNAME=localhost
    DB_USERNAME=postgres
    DB_DATABASE_NAME=immich
    DB_PASSWORD=postgres
    
    REDIS_HOSTNAME=localhost
    
    # Path where Immich will store its assets
    IMMICH_MEDIA_LOCATION="/mnt/data"
    

build web​

  1. navigate to web dir in the immich git repo
  2. npm ci
  3. npm run build
  4. npm prune --omit=dev
  5. mkdir /usr/local/www/immich/web
  6. cp -R ./ /usr/local/www/immich/web
  7. chown -R immich:wheel /usr/local/www/immich
  8. create immich_web service script in /usr/local/etc/rc.d (make sure it's executable)
    Code:
    #!/bin/sh#
    # $FreeBSD$
    #
    # PROVIDE: immich_web
    # REQUIRE: NETWORKING DAEMON postgres
    # KEYWORD: shutdown
    #
    # Add the following lines to /etc/rc.conf:
    #
    #immich_web_enable="YES"
    . /etc/rc.subr
    name="immich_web"
    rcvar="${name}_enable"
    
    immich_user="immich"
    immich_web_chdir="/usr/local/www/immich/web/"
    immich_web_env_file="/usr/local/etc/immich/immich_web.env"
    immich_web_env="NODE_ENV=production"
    pidfile="/var/run/${name}.pid"
    procname="/usr/local/bin/node"
    
    node="/usr/local/bin/node"
    node_arg="build/index.js"
    
    command="/usr/sbin/daemon"
    command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"
    
    load_rc_config ${name}
    run_rc_command "$1"
  9. create immich_web.env in /usr/local/etc/immich
    Code:
    # You can find documentation for all the supported env variables at https://imm>
    # Port where the web application will listen. Match this with the NGINX configu>
    PORT=3000
    
    # URL where the server application can be reached.
    IMMICH_SERVER_URL=http://localhost:3001
    PUBLIC_IMMICH_SERVER_URL=http://localhost:3001
    
  10. create a immich.conf in /usr/local/www/nginx
    Code:
    server { 
      server_name localhost;
      listen 80;
    
      access_log off;
      client_max_body_size 50000M;
    
      # Compression
      gzip off;
      gzip_comp_level 2;
      gzip_min_length 1000;
      gzip_proxied any;
      gzip_vary on;
      gunzip on;
    
      # text/html is included by default
      gzip_types
        application/javascript
        application/json
        font/ttf
        image/svg+xml
        text/css;
    
      location /api {
        proxy_buffering off;
        proxy_buffer_size 16k;
        proxy_busy_buffers_size 24k;
        proxy_buffers 64 4k;
        proxy_force_ranges on;
    
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
    
        rewrite /api/(.*) /$1 break;
        proxy_pass "http://localhost:3001/";
      }
    
      location / {
        proxy_buffering off;
        proxy_buffer_size 16k;
        proxy_busy_buffers_size 24k;
        proxy_buffers 64 4k;
        proxy_force_ranges on;
    
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
    
        proxy_pass "http://localhost:3000/";
      }
    }
  11. include that conf under the http tag in the nginx conf (probably want to remove the template servers in that file too)
  12. check the nginx config with, nginx -t
  13. service nginx start
  14. service immich_microservices start
  15. service immich_server start
  16. service immich_web start
And hopefully that does it for you. You should be able to go in your browser to your jail's ip address and immich will be there. You can check in /var/log/debug.log to see some logs. I'm running typesense elsewhere to get the search functionality to work. Just need to add to the immich_server.env, like the host name. Environment variables can be seen here: https://immich.app/docs/install/environment-variables. I haven't tried getting the machine learning to work, but maybe someone else will have luck doing that.

Hope this helps! (and hope I didn't miss anything)
Hi,

I feel so clueless, I just built my TrueNas Core. A lot of the stuff you're saying doesn't register with me.
I understand what you mean by clone immich, how do I do that? And, how do I run the "npm" command?
I ran npm and it comes back with command not found. I am an illiterate when it comes to this stuff. Please
feel free to talk to me like I'm a noob, because I am!!! :) Thank you!

-RB
 

ps23Rick

Cadet
Joined
Nov 14, 2023
Messages
8
Hi @riotbob … the above directions assume that you’ve got some things installed, one of them is npm. Just remember that TrueNAS is sitting on top of a FreeBSD operating system. So you’ll need to get familiar with installing some things to get this going — in the terminal window.

Depending on how adventuresome you might be, that will dictate a lot. This is not the greatest starter project in my opinion as it’s got a lot of things going on to get this going and assumes some familiarity with how to do certain things. If there are other areas of TrueNAS / FreeBSD that you’d like to get familiar with first, that might be a really good idea…. Perhaps someone else might have a different suggestion…‍
 
Last edited:

riotbob

Cadet
Joined
Nov 7, 2023
Messages
4
Hi @riotbob … the above directions assume that you’ve got some things installed, one of them is npm. Just remember that TrueNAS is sitting on top of a FreeBSD operating system. So you’ll need to get familiar with installing some things to get this going — in the terminal window.

Depending on how adventuresome you might be, that will dictate a lot. This is not the greatest starter project in my opinion as it’s got a lot of things going on to get this going and assumes some familiarity with how to do certain things. If there are other areas of TrueNAS / FreeBSD that you’d like to get familiar with first, that might be a really good idea…. Perhaps someone else might have a different suggestion…‍
Thanks, PS23Rick. I'll have to get more familiar with FreeBSD...
 

teawrecks

Cadet
Joined
May 7, 2018
Messages
5
Thanks for the guide, this got me up and running with 1.84.0.

I'm wondering if anyone has had luck with more recent versions, or the android app.

I tried building more recent versions. v1.92.1 is the most recent that seems to build clean, but when I swap out the dirs in /usr/local/www/immich the services no longer launch. Any versions after that seem to have build issues for me (latest right now is v1.94.1).

As for the app, the latest on f-droid seems to be 1.93.2, and it refuses to log into my server (says my email/pw is wrong).
 
Top