From 24f47a390dce2414a97409052b5e87837f686214 Mon Sep 17 00:00:00 2001 From: Armando Camarero Date: Thu, 17 Aug 2023 18:28:18 +0200 Subject: [PATCH] Add changes for new ports for Immich --- GIDs | 2 +- UIDs | 2 +- net/immich_server/Makefile | 72 +++++++++++++++++++ net/immich_server/distinfo | 3 + .../files/immich_microservices.in | 37 ++++++++++ net/immich_server/files/immich_server.in | 37 ++++++++++ .../files/patch-docker_example.env | 46 ++++++++++++ net/immich_server/pkg-descr | 1 + net/immich_web/Makefile | 61 ++++++++++++++++ net/immich_web/distinfo | 3 + net/immich_web/files/immich-nginx.sample | 61 ++++++++++++++++ net/immich_web/files/immich_web.in | 37 ++++++++++ net/immich_web/files/patch-docker_example.env | 34 +++++++++ net/immich_web/pkg-descr | 1 + 14 files changed, 395 insertions(+), 2 deletions(-) create mode 100644 net/immich_server/Makefile create mode 100644 net/immich_server/distinfo create mode 100644 net/immich_server/files/immich_microservices.in create mode 100644 net/immich_server/files/immich_server.in create mode 100644 net/immich_server/files/patch-docker_example.env create mode 100644 net/immich_server/pkg-descr create mode 100644 net/immich_web/Makefile create mode 100644 net/immich_web/distinfo create mode 100644 net/immich_web/files/immich-nginx.sample create mode 100644 net/immich_web/files/immich_web.in create mode 100644 net/immich_web/files/patch-docker_example.env create mode 100644 net/immich_web/pkg-descr diff --git a/GIDs b/GIDs index 26cfd95b88d7..d433cdf1312b 100644 --- a/GIDs +++ b/GIDs @@ -621,7 +621,7 @@ riak:*:667: # free: 677 # free: 678 # free: 679 -# free: 680 +immich:*:680: # free: 681 # free: 682 # free: 683 diff --git a/UIDs b/UIDs index 61f105288259..b196cf3fd55c 100644 --- a/UIDs +++ b/UIDs @@ -626,7 +626,7 @@ stanchion:*:669:667::0:0:Stanchion user:/usr/local/lib/stanchion:/bin/sh # free: 677 # free: 678 # free: 679 -# free: 680 +immich:*:680:680::0:0:Immich user:/nonexistent:/usr/sbin/nologin # free: 681 # free: 682 # free: 683 diff --git a/net/immich_server/Makefile b/net/immich_server/Makefile new file mode 100644 index 000000000000..dee0d8eae74b --- /dev/null +++ b/net/immich_server/Makefile @@ -0,0 +1,72 @@ +PORTNAME= immich_server +DISTVERSIONPREFIX= v +DISTVERSION= 1.73.0 +CATEGORIES= net + +MAINTAINER= arcepi@arcepi.net +COMMENT= Self-hosted backup solution for photos and videos on mobile devices +WWW= https://immich.app/ + +LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE + +BUILD_DEPENDS= npm:www/npm-node18 vips:graphics/vips +RUN_DEPENDS= ffmpeg:multimedia/ffmpeg vips:graphics/vips + +# USES=gettext-runtime +USES= nodejs:lts,build,run shebangfix gnome pgsql:14 +USE_GNOME= glib20 +WANT_PGSQL= contrib server client +USE_GITHUB= yes +GH_ACCOUNT= immich-app +GH_PROJECT= immich + +IMMICH_PATH= www/immich +IMMICH_PATH_PREFIX= ${STAGEDIR}${PREFIX}/${IMMICH_PATH} +IMMICH_SERVER_PREFIX= ${IMMICH_PATH_PREFIX}/server/ + +SHEBANG_FILES+= server/bin/*.sh + +USE_RC_SUBR= immich_server immich_microservices + +PLIST= ${WRKDIR}/PLIST + +USERS= immich +GROUPS= immich + +do-build: + cd ${WRKSRC}/server; npm ci + cd ${WRKSRC}/server; npm run build + cd ${WRKSRC}/server; npm prune --omit=dev --omit=optional + +pre-install: + @${ECHO_MSG} "===> Generating (custom) packing list" + ${RM} ${PLIST} + ${ECHO_CMD} "@comment >>>>> GENERATED FILE, DO NOT EDIT <<<<<" >> ${PLIST} + ${ECHO_CMD} "@comment Alter post-install target and regenerate as required" >> ${PLIST} + ${ECHO_CMD} "@owner immich" >> ${PLIST} + ${ECHO_CMD} "@group wheel" >> ${PLIST} + ${ECHO_CMD} "@sample etc/immich/immich_server.env.sample etc/immich/immich_server.env" >>${PLIST} + ${FIND} ${WRKSRC}/server -type f |${SED} -e "s|${WRKSRC}|${IMMICH_PATH}|" >>${PLIST} + +do-install: + ${MKDIR} ${IMMICH_SERVER_PREFIX} + ${CP} -R ${WRKSRC}/server ${IMMICH_PATH_PREFIX} + ${MKDIR} ${STAGEDIR}${PREFIX}/etc/immich/ + ${CP} ${WRKSRC}/docker/example.env ${STAGEDIR}${PREFIX}/etc/immich/immich_server.env.sample + ${CHOWN} -R immich:wheel ${IMMICH_PATH_PREFIX} + +post-install: + ${STRIP_CMD} ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node + ${STRIP_CMD} ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/bcrypt/build-tmp-napi-v3/Release/obj.target/bcrypt_lib.node + ${STRIP_CMD} ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/bcrypt/build-tmp-napi-v3/Release/bcrypt_lib.node + ${STRIP_CMD} ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/sharp/build/Release/obj.target/sharp-freebsd-x64.node + ${STRIP_CMD} ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/sharp/build/Release/sharp-freebsd-x64.node + + ${SED} -i '' -e "1s|/bin/bash|${LOCALBASE}/bin/bash|" ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/fluent-ffmpeg/tools/test-travis.sh + ${SED} -i '' -e "1s|/usr/bin/perl|${LOCALBASE}/bin/perl|" ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/exiftool-vendored.pl/bin/validate + ${SED} -i '' -e "1s|/usr/bin/perl|${LOCALBASE}/bin/perl|" ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/exiftool-vendored.pl/bin/build_tag_lookup + ${SED} -i '' -e "1s|/usr/bin/perl|${LOCALBASE}/bin/perl|" ${STAGEDIR}${PREFIX}/www/immich/server/node_modules/exiftool-vendored.pl/bin/exiftool + + +.include diff --git a/net/immich_server/distinfo b/net/immich_server/distinfo new file mode 100644 index 000000000000..36ed9e38aba8 --- /dev/null +++ b/net/immich_server/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1692282134 +SHA256 (immich-app-immich-v1.73.0_GH0.tar.gz) = e70875a474bea7c886a3c254f23be0886e8f012e16f11d46c96378e10a27c110 +SIZE (immich-app-immich-v1.73.0_GH0.tar.gz) = 75159687 diff --git a/net/immich_server/files/immich_microservices.in b/net/immich_server/files/immich_microservices.in new file mode 100644 index 000000000000..89a86f7746f7 --- /dev/null +++ b/net/immich_server/files/immich_microservices.in @@ -0,0 +1,37 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: immich_microservices +# REQUIRE: NETWORKING DAEMON postgres +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to immich_web: +# +#immich_microservices_enable="YES" + +. /etc/rc.subr + +name="immich_microservices" +rcvar="${name}_enable" + +#immich_web_user="immich" +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" \ No newline at end of file diff --git a/net/immich_server/files/immich_server.in b/net/immich_server/files/immich_server.in new file mode 100644 index 000000000000..38f85805f8c6 --- /dev/null +++ b/net/immich_server/files/immich_server.in @@ -0,0 +1,37 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: immich_web +# REQUIRE: NETWORKING DAEMON postgres redis +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to immich_web: +# +#immich_server_enable="YES" + +. /etc/rc.subr + +name="immich_server" +rcvar="${name}_enable" + +#immich_web_user="immich" +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" \ No newline at end of file diff --git a/net/immich_server/files/patch-docker_example.env b/net/immich_server/files/patch-docker_example.env new file mode 100644 index 000000000000..46789874e587 --- /dev/null +++ b/net/immich_server/files/patch-docker_example.env @@ -0,0 +1,46 @@ +--- docker/example.env.orig 2023-08-17 15:30:50 UTC ++++ docker/example.env +@@ -1,19 +1,30 @@ + # 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 ++TYPESENSE_API_KEY=some-random-text ++TYPESENSE_ENABLED=false + +-# The Immich version to use. You can pin this to a specific version like "v1.71.0" +-IMMICH_VERSION=release ++DB_HOSTNAME=localhost ++#DB_USERNAME=postgres ++#DB_PASSWORD=password ++#DB_DATABASE=immich + +-# Connection secrets for postgres and typesense. You should change these to random passwords +-TYPESENSE_API_KEY=some-random-text +-DB_PASSWORD=postgres ++REDIS_HOSTNAME=localhost + +-# The values below this line do not need to be changed + ################################################################################### +-DB_HOSTNAME=immich_postgres +-DB_USERNAME=postgres +-DB_DATABASE_NAME=immich ++# This example file is heavily modified with respect with the included sample ++# for the standard docker deployment. ++# ++# The listed variables are applicable and neccessary for the server and microservices ++# when running outside Docker. ++################################################################################### ++# Path where Immich will store its assets ++IMMICH_MEDIA_LOCATION=absolute_location_on_your_machine_where_you_want_to_store_the_backup + +-REDIS_HOSTNAME=immich_redis +\ No newline at end of file ++# Port where the Immich server application will listen. ++#SERVER_PORT=3001 ++ ++# Port where the Immich microservices will listen. ++#MICROSERVICES_PORT=3002 ++ ++# Disable immich machine learning. Not yet available for FreeBSD. ++IMMICH_MACHINE_LEARNING_URL=false diff --git a/net/immich_server/pkg-descr b/net/immich_server/pkg-descr new file mode 100644 index 000000000000..c8f5fdcca35c --- /dev/null +++ b/net/immich_server/pkg-descr @@ -0,0 +1 @@ +Self hosted photos and videos backup tool. diff --git a/net/immich_web/Makefile b/net/immich_web/Makefile new file mode 100644 index 000000000000..e584e6ca394e --- /dev/null +++ b/net/immich_web/Makefile @@ -0,0 +1,61 @@ +PORTNAME= immich_web +DISTVERSIONPREFIX= v +DISTVERSION= 1.73.0 +CATEGORIES= net + +MAINTAINER= arcepi@arcepi.net +COMMENT= Self-hosted backup solution for photos and videos on mobile devices +WWW= https://immich.app/ + +LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE + +BUILD_DEPENDS= npm:www/npm-node18 + +USES= nodejs:lts,build,run +USE_GITHUB= yes +GH_ACCOUNT= immich-app +GH_PROJECT= immich + +IMMICH_PATH= www/immich +IMMICH_PATH_PREFIX= ${STAGEDIR}${PREFIX}/${IMMICH_PATH} +IMMICH_WEB_PREFIX= ${IMMICH_PATH_PREFIX}/web + +NO_ARCH= yes + +USE_RC_SUBR= immich_web + +PLIST= ${WRKDIR}/PLIST + +USERS= immich +GROUPS= immich + +post-patch: + ${CP} ${PATCHDIR}/immich-nginx.sample ${WRKSRC} + +do-build: + cd ${WRKSRC}/web; npm ci + cd ${WRKSRC}/web; npm run build + cd ${WRKSRC}/web; npm prune --omit=dev + +pre-install: + @${ECHO_MSG} "===> Generating (custom) packing list" + ${RM} ${PLIST} + ${ECHO_CMD} "@comment >>>>> GENERATED FILE, DO NOT EDIT <<<<<" >> ${PLIST} + ${ECHO_CMD} "@comment Alter post-install target and regenerate as required" >> ${PLIST} + ${ECHO_CMD} "@owner immich" >> ${PLIST} + ${ECHO_CMD} "@group wheel" >> ${PLIST} + ${ECHO_CMD} "@sample etc/immich/immich_web.env.sample etc/immich/immich_web.env" >> ${PLIST} + ${ECHO_CMD} "@sample etc/nginx/immich-nginx.sample etc/nginx/immich-nginx" >> ${PLIST} + ${FIND} ${WRKSRC}/web -type f |${SED} -e "s|${WRKSRC}|${IMMICH_PATH}|" >>${PLIST} + +do-install: + ${MKDIR} ${IMMICH_WEB_PREFIX} + ${CP} -R ${WRKSRC}/web ${IMMICH_PATH_PREFIX} + ${MKDIR} ${STAGEDIR}${PREFIX}/etc/immich/ + ${CP} ${WRKSRC}/docker/example.env ${STAGEDIR}${PREFIX}/etc/immich/immich_web.env.sample + ${MKDIR} ${STAGEDIR}${PREFIX}/etc/nginx/ + ${CP} ${WRKSRC}/immich-nginx.sample ${STAGEDIR}${PREFIX}/etc/nginx/immich-nginx.sample + ${CHOWN} -R immich:wheel ${IMMICH_PATH_PREFIX} + +.include diff --git a/net/immich_web/distinfo b/net/immich_web/distinfo new file mode 100644 index 000000000000..36ed9e38aba8 --- /dev/null +++ b/net/immich_web/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1692282134 +SHA256 (immich-app-immich-v1.73.0_GH0.tar.gz) = e70875a474bea7c886a3c254f23be0886e8f012e16f11d46c96378e10a27c110 +SIZE (immich-app-immich-v1.73.0_GH0.tar.gz) = 75159687 diff --git a/net/immich_web/files/immich-nginx.sample b/net/immich_web/files/immich-nginx.sample new file mode 100644 index 000000000000..1eb3f84fdfb2 --- /dev/null +++ b/net/immich_web/files/immich-nginx.sample @@ -0,0 +1,61 @@ +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/"; + } + + +} diff --git a/net/immich_web/files/immich_web.in b/net/immich_web/files/immich_web.in new file mode 100644 index 000000000000..eff6b891c393 --- /dev/null +++ b/net/immich_web/files/immich_web.in @@ -0,0 +1,37 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: immich_web +# REQUIRE: NETWORKING DAEMON postgres +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to immich_web: +# +#immich_web_enable="YES" + +. /etc/rc.subr + +name="immich_web" +rcvar="${name}_enable" + +#immich_web_user="immich" +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" \ No newline at end of file diff --git a/net/immich_web/files/patch-docker_example.env b/net/immich_web/files/patch-docker_example.env new file mode 100644 index 000000000000..62cfc38682c1 --- /dev/null +++ b/net/immich_web/files/patch-docker_example.env @@ -0,0 +1,34 @@ +--- docker/example.env.orig 2023-08-17 15:31:55 UTC ++++ docker/example.env +@@ -1,19 +1,15 @@ + # 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_API_KEY=some-random-text +-DB_PASSWORD=postgres +- +-# The values below this line do not need to be changed + ################################################################################### +-DB_HOSTNAME=immich_postgres +-DB_USERNAME=postgres +-DB_DATABASE_NAME=immich ++# This example file is heavily modified with respect with the included sample ++# for the standard docker deployment. ++# ++# The listed variables are applicable and neccessary for web service ++# when running outside Docker. ++################################################################################### ++# Port where the web application will listen. Match this with the NGINX configuration. ++#PORT=3000 + +-REDIS_HOSTNAME=immich_redis +\ No newline at end of file ++# URL where the server application can be reached. ++IMMICH_SERVER_URL=http://localhost:3001 ++PUBLIC_IMMICH_SERVER_URL=http://localhost:3001 diff --git a/net/immich_web/pkg-descr b/net/immich_web/pkg-descr new file mode 100644 index 000000000000..6b33c7774284 --- /dev/null +++ b/net/immich_web/pkg-descr @@ -0,0 +1 @@ +Self hosted photos and videos backup tool. \ No newline at end of file -- 2.41.0