Skip to content
34 changes: 31 additions & 3 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -11972,7 +11972,8 @@ _EOF_
then
# Install pgvector and VectorChord extensions: https://immich.app/docs/administration/postgres-standalone
local pg_version=$(find /etc/postgresql -mindepth 1 -maxdepth 1 -type d -name '[1-9][0-9]' -printf '%f\n' | sort -Vr | head -1)
aDEPS=("postgresql-$pg_version-pgvector")
# Build dependencies for libvips with HEIC support
aDEPS=("postgresql-$pg_version-pgvector" 'git' 'make' 'cmake' 'meson' 'ninja-build' 'pkg-config' 'libglib2.0-dev' 'libexpat1-dev' 'libexif-dev' 'libjpeg-dev' 'libpng-dev' 'libwebp-dev' 'libde265-dev' 'libx265-dev' 'libheif-plugin-x265')
local arch='amd64'
(( $G_HW_ARCH == 3 )) && local arch='arm64'
local fallback_url="https://github.com/tensorchord/VectorChord/releases/download/1.1.0/postgresql-$pg_version-vchord_1.1.0-1_$arch.deb"
Expand Down Expand Up @@ -12015,19 +12016,46 @@ _EOF_
# Prevent JavaScript OOM during build
export NODE_OPTIONS='--max-old-space-size=4096'

# Build libheif from source with x265 and de265 encoders enabled
# System libheif1 doesn't have proper x265 encoding support, plugins don't work reliably
G_DIETPI-NOTIFY 2 'Building latest libheif from source with x265 encoder support...'
G_EXEC git clone --depth=1 https://github.com/strukturag/libheif.git
G_EXEC cd libheif
G_EXEC cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_X265=ON -DWITH_LIBDE265=ON -DWITH_EXAMPLES=OFF
G_EXEC cmake --build build --parallel
G_EXEC cmake --install build
G_EXEC cd "$immich_src"
G_EXEC rm -rf libheif
G_EXEC ldconfig /usr/local/lib

# Build libvips from source for full HEIC support
# Sharp 0.34.5+ requires libvips 8.17.3+, but system packages only provide 8.15.1
G_DIETPI-NOTIFY 2 'Building latest libvips from source for HEIC support...'
G_EXEC git clone --depth=1 https://github.com/libvips/libvips.git
G_EXEC cd libvips
G_EXEC meson setup build --buildtype=release --libdir=lib -Dintrospection=disabled
G_EXEC ninja -C build install
G_EXEC cd "$immich_src"
G_EXEC rm -rf libvips
G_EXEC ldconfig /usr/local/lib

# Force Sharp to use system libvips with HEIC support
export SHARP_FORCE_GLOBAL_LIBVIPS=true

# Install Node dependencies
G_EXEC_OUTPUT=1 G_EXEC pnpm --filter immich --filter @immich/sdk --filter immich-web --filter plugins i

# Build Immich server, web UI (requires Immich SDK), and WebAssembly workflow plugin
G_EXEC_OUTPUT=1 G_EXEC pnpm --filter immich --filter @immich/sdk --filter immich-web --filter plugins build

# Remove build-time tools
# Remove build-time tools and dependencies
G_EXEC rm /usr/local/bin/extism-js /usr/local/bin/wasm-merge /usr/local/bin/wasm-opt
G_AGP git make cmake meson ninja-build pkg-config libglib2.0-dev libexpat1-dev libexif-dev libjpeg-dev libpng-dev libwebp-dev libde265-dev libx265-dev libheif-plugin-x265

# Deploy server
[[ -d '/opt/immich' ]] && G_EXEC rm -R /opt/immich
G_EXEC_OUTPUT=1 G_EXEC pnpm --filter immich -P deploy /opt/immich
unset -v NODE_OPTIONS
unset -v NODE_OPTIONS SHARP_FORCE_GLOBAL_LIBVIPS

# Install web frontend and WebAssembly workflow plugin
G_EXEC mv web/build /opt/immich/www
Expand Down