diff --git a/www/immich/Makefile b/www/immich/Makefile index eda7a7539a83..d1a625c386fa 100644 --- a/www/immich/Makefile +++ b/www/immich/Makefile @@ -1,123 +1,123 @@ PORTNAME= immich DISTVERSIONPREFIX= v DISTVERSION= 3.2.2 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= www MASTER_SITES= https://github.com/joneum/FreeBSD-Immich/releases/download/v${DISTVERSION}/:buildkit DISTFILES= immich-freebsd-buildkit-${DISTVERSION}${EXTRACT_SUFX}:buildkit MAINTAINER= joneum@FreeBSD.org COMMENT= High performance self-hosted photo and video management solution WWW= https://immich.app/ LICENSE= AGPLv3 LICENSE_FILE= ${WRKSRC}/LICENSE ONLY_FOR_ARCHS= aarch64 amd64 ONLY_FOR_ARCHS_REASON= native Node.js modules are only tested on \ 64-bit platforms BUILD_DEPENDS= ${LOCALBASE}/bin/npm:www/npm-node22 LIB_DEPENDS= libheif.so:graphics/libheif \ libraw.so:graphics/libraw \ libvips.so:graphics/vips RUN_DEPENDS= ${LOCALBASE}/bin/gzip:archivers/gzip \ exiftool:graphics/p5-Image-ExifTool \ ${LOCALBASE}/bin/jellyfin-ffmpeg8:multimedia/jellyfin-ffmpeg USES= cpe gettext-runtime gmake gnome nodejs:22,build,run pgsql:14+ \ pkgconfig python:build CPE_VENDOR= futo WANT_PGSQL= client USE_GNOME= glib20 USE_GITHUB= yes GH_ACCOUNT= immich-app USE_RC_SUBR= immich_server # The buildkit distfile carries the pnpm store, the pnpm tarball, the # geodata and the core plugin, so that the build needs no network. It is # made by unpacking the release tarball and running, with the pnpm version # from packageManager in package.json: # pnpm install --frozen-lockfile --ignore-scripts --store-dir /pnpm-store # cd && npm pack pnpm@ # plus the geodata files from geonames.org and natural-earth-vector, and # the immich-plugin-core payload from the upstream container image. BUILDKIT= ${WRKDIR}/immich-freebsd-buildkit-${DISTVERSION} PNPM= ${WRKDIR}/pnpm-prefix/bin/pnpm PNPM_VERSION= 11.22.0 MAKE_ENV= CI=1 \ COREPACK_ENABLE_STRICT=0 \ NODE_OPTIONS=--max-old-space-size=4096 \ npm_config_build_from_source=true \ npm_config_nodedir=${LOCALBASE} \ npm_config_python=${PYTHON_CMD} \ PYTHON=${PYTHON_CMD} \ SHARP_FORCE_GLOBAL_LIBVIPS=1 SUB_FILES= pkg-message SUB_LIST= NODE=${LOCALBASE}/bin/node USERS= immich GROUPS= immich post-patch: @${REINPLACE_CMD} -e 's|/usr/lib/postgresql/[^/]*/bin/|${LOCALBASE}/bin/|' \ ${WRKSRC}/server/src/services/database-backup.service.ts pre-build: cd ${WRKDIR} && ${SETENV} PATH=${PATH} \ npm install -g --prefix ${WRKDIR}/pnpm-prefix \ ${BUILDKIT}/pnpm-${PNPM_VERSION}.tgz do-build: cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \ ${PNPM} install --offline --frozen-lockfile \ --store-dir ${BUILDKIT}/pnpm-store cd $$(${ECHO_CMD} ${WRKSRC}/node_modules/.pnpm/sharp@*/node_modules/sharp) && \ ${SETENV} ${MAKE_ENV} ${LOCALBASE}/bin/node install/build.js cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \ ${PNPM} --filter @immich/plugin-sdk --filter @immich/sdk \ --filter immich build cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \ ${PNPM} --filter immich-web build cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \ ${PNPM} --store-dir ${BUILDKIT}/pnpm-store --filter immich \ --prod --no-optional deploy ${WRKDIR}/server-pruned cd $$(${ECHO_CMD} ${WRKDIR}/server-pruned/node_modules/.pnpm/sharp@*/node_modules/sharp) && \ ${SETENV} ${MAKE_ENV} ${LOCALBASE}/bin/node install/build.js do-install: ${INSTALL_DATA} ${FILESDIR}/immich.env.sample ${STAGEDIR}${PREFIX}/etc/ @${MKDIR} ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d ${INSTALL_DATA} ${FILESDIR}/newsyslog-immich.conf \ ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d/immich.conf ${MKDIR} ${STAGEDIR}${WWWDIR}/server \ ${STAGEDIR}${WWWDIR}/build-data/www \ ${STAGEDIR}${WWWDIR}/build-data/geodata \ ${STAGEDIR}${WWWDIR}/build-data/plugins/immich-plugin-core cd ${WRKDIR}/server-pruned && ${PAX} -rw . ${STAGEDIR}${WWWDIR}/server cd ${WRKSRC}/web/build && ${PAX} -rw . ${STAGEDIR}${WWWDIR}/build-data/www cd ${BUILDKIT}/geodata && ${PAX} -rw . ${STAGEDIR}${WWWDIR}/build-data/geodata cd ${BUILDKIT}/plugins/immich-plugin-core && ${PAX} -rw . \ ${STAGEDIR}${WWWDIR}/build-data/plugins/immich-plugin-core ${MKDIR} ${STAGEDIR}/var/db/immich ${STAGEDIR}/var/log/immich post-install: @${FIND} ${STAGEDIR}${WWWDIR}/server/node_modules -type f \ \( -name "*.sh" -o -name "*.py" -o -name build_tag_lookup \ -o -name validate \) -exec ${CHMOD} a-x {} + @${FIND} ${STAGEDIR}${WWWDIR}/server -type d \ \( -name .tmp -o -name .deps -o -name nothing \) \ -exec ${RM} -r {} + 2>/dev/null || ${TRUE} @${FIND} ${STAGEDIR}${WWWDIR}/server -type f \ \( -name "*.map" -o -name "*.d.ts" \) -delete @${FIND} ${STAGEDIR}${WWWDIR}/server -type d \ \( -name test -o -name tests -o -name __tests__ \ -o -name coverage \) -exec ${RM} -r {} + 2>/dev/null || ${TRUE} @${FIND} ${STAGEDIR}${WWWDIR}/server -type d -empty -delete .include diff --git a/www/immich/files/immich_server.in b/www/immich/files/immich_server.in index ab04d1c63258..66642338d12c 100644 --- a/www/immich/files/immich_server.in +++ b/www/immich/files/immich_server.in @@ -1,103 +1,105 @@ #!/bin/sh # PROVIDE: immich_server # REQUIRE: LOGIN postgresql valkey # KEYWORD: shutdown # # Add these lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # immich_server_enable (bool): Set to NO by default. # Set it to YES to enable immich-server. # immich_server_media_location (str): Upload/media location. # Default: /var/db/immich # immich_server_host (str): Listen address. Default: 0.0.0.0 # immich_server_port (int): Listen port. Default: 2283 # immich_server_env_file (str): Environment file with additional # IMMICH_*/DB_*/REDIS_* variables. # Default: %%PREFIX%%/etc/immich.env . /etc/rc.subr name=immich_server rcvar=immich_server_enable load_rc_config $name : ${immich_server_enable:=NO} : ${immich_server_user:=immich} : ${immich_server_group:=immich} : ${immich_server_media_location:=/var/db/immich} : ${immich_server_host:=0.0.0.0} : ${immich_server_port:=2283} +: ${immich_server_ml_url:=http://127.0.0.1:3003} : ${immich_server_env_file:=%%PREFIX%%/etc/immich.env} : ${immich_server_env:="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ HOME=${immich_server_media_location} \ NODE_ENV=production \ IMMICH_BUILD_DATA=%%PREFIX%%/www/immich/build-data \ IMMICH_MEDIA_LOCATION=${immich_server_media_location} \ IMMICH_HOST=${immich_server_host} \ IMMICH_PORT=${immich_server_port} \ + IMMICH_MACHINE_LEARNING_URL=${immich_server_ml_url} \ FFMPEG_PATH=%%PREFIX%%/bin/jellyfin-ffmpeg8 \ FFPROBE_PATH=%%PREFIX%%/bin/jellyfin-ffprobe8"} pidfile=/var/run/immich/${name}.pid childpidfile=/var/run/immich/${name}_child.pid required_dirs="%%PREFIX%%/www/immich/server" immich_server_chdir=%%PREFIX%%/www/immich/server start_precmd=immich_server_precmd stop_cmd=immich_server_stop command=/usr/sbin/daemon command_args="-f -S -H -P ${pidfile} -p ${childpidfile} \ -o /var/log/immich/${name}.log \ %%NODE%% dist/main" immich_server_stop() { local pid pid=$(check_pidfile ${pidfile} ${command}) if [ -z "$pid" ]; then echo "${name} not running? (check ${pidfile})." return 1 fi echo "Stopping ${name}." kill -TERM -- -${pid} 2>/dev/null || kill -TERM ${pid} wait_for_pids ${pid} rm -f ${pidfile} ${childpidfile} } immich_server_precmd() { # Keep what the service creates itself out of other users' reach umask 027 local cpid spid n # A kill -9 on the supervisor leaves its child behind, holding the # listen socket. Clean that up before starting a second one. if [ -f ${childpidfile} ]; then cpid=$(cat ${childpidfile} 2>/dev/null) spid=$(cat ${pidfile} 2>/dev/null) if [ -n "${cpid}" ] && kill -0 ${cpid} 2>/dev/null && \ { [ -z "${spid}" ] || ! kill -0 ${spid} 2>/dev/null; }; then echo "Removing leftover ${name} process ${cpid}." kill -TERM -- -${cpid} 2>/dev/null || kill -TERM ${cpid} wait_for_pids ${cpid} # The child forks workers of its own, wait for the # listen socket to be released before starting again. n=0 while sockstat -4l -p ${immich_server_port} 2>/dev/null | \ grep -q ${immich_server_user}; do [ ${n} -ge 20 ] && break sleep 1 n=$((n + 1)) done rm -f ${pidfile} ${childpidfile} fi fi install -d -m 750 -o ${immich_server_user} -g ${immich_server_group} \ /var/run/immich /var/log/immich ${immich_server_media_location} } run_rc_command "$1" diff --git a/www/immich/files/pkg-message.in b/www/immich/files/pkg-message.in index 82c5bc9ca738..32387cc85e6e 100644 --- a/www/immich/files/pkg-message.in +++ b/www/immich/files/pkg-message.in @@ -1,80 +1,80 @@ [ { type: install message: < Settings > - Machine Learning) to http://127.0.0.1:3003 + detection, facial recognition and text search in images. The rc + script points the server at it on 127.0.0.1:3003; a service on + another host goes into immich_server_ml_url. Running it: * The server listens on all addresses, and its worker opens a second port on a random number as well. Both follow sysrc immich_server_host=127.0.0.1 so set that and put a reverse proxy with TLS in front of it. The same goes for www/immich-public-proxy, which faces the internet. * Back up both the database and the media directory. The built-in database backup writes to the backups folder below the media location and does not include the media itself. To restore one of those dumps into an empty database: su -l postgres -c "createdb -O immich immich" su -l postgres -c "psql -q -d immich -c 'CREATE EXTENSION vector'" su -l postgres -c "psql -q -d immich -c 'CREATE EXTENSION vchord CASCADE'" gzip -dc .sql.gz | su -l postgres -c "psql -q -d immich" The extensions have to exist before the dump is loaded. * Sizing: the service itself needs about 1 GB of disk, the machine learning models another 1 GB, and the two node processes sit at roughly 800 MB of memory when idle. Give the machine 8 GB. * Files are stored under random names unless you set a storage template in the admin interface. Doing that before the first import keeps the library readable without the database. * Logs are rotated by newsyslog through %%PREFIX%%/etc/newsyslog.conf.d/immich.conf. * Video work runs through multimedia/jellyfin-ffmpeg, which the rc script selects with FFMPEG_PATH and FFPROBE_PATH. Immich builds its HDR filter chain around tonemapx, a filter multimedia/ffmpeg does not provide, so with plain ffmpeg an HDR video gets no thumbnail at all. To use a different build, set both variables in immich.env. * Schema migrations run automatically on start, so take a backup before a version upgrade; downgrades are not supported. After a PostgreSQL major upgrade, rebuild pgvector and vchord. After a Node major upgrade, rebuild this port so the native modules match. The web interface listens on port 2283 by default. The upload location defaults to /var/db/immich and can be changed with sysrc immich_server_media_location=/path. EOM } ]