Immich: some cleanup

This commit is contained in:
vhsdream 2025-05-06 15:02:04 -04:00
parent 74aa2b599e
commit aa3be7403e
2 changed files with 52 additions and 51 deletions

View File

@ -32,7 +32,7 @@ function update_script() {
SOURCE_DIR=${STAGING_DIR}/image-source SOURCE_DIR=${STAGING_DIR}/image-source
if [[ -f ~/.intel_version ]]; then if [[ -f ~/.intel_version ]]; then
curl -fsSLO https://raw.githubusercontent.com/immich-app/immich/refs/heads/main/machine-learning/Dockerfile curl -fsSLO https://raw.githubusercontent.com/immich-app/immich/refs/heads/main/machine-learning/Dockerfile
readarray INTEL_URLS <<<"$(sed -n "/intel/p" ./Dockerfile | awk '{print $3}')" readarray -t INTEL_URLS <<<"$(sed -n "/intel/p" ./Dockerfile | awk '{print $3}')"
INTEL_RELEASE="$(grep "intel-opencl-icd" ./Dockerfile | awk -F '_' '{print $2}')" INTEL_RELEASE="$(grep "intel-opencl-icd" ./Dockerfile | awk -F '_' '{print $2}')"
if [[ "$INTEL_RELEASE" != "$(cat ~/.intel_version)" ]]; then if [[ "$INTEL_RELEASE" != "$(cat ~/.intel_version)" ]]; then
msg_info "Updating Intel iGPU dependencies" msg_info "Updating Intel iGPU dependencies"
@ -43,13 +43,14 @@ function update_script() {
rm ./*.deb rm ./*.deb
msg_ok "Intel iGPU dependencies updated" msg_ok "Intel iGPU dependencies updated"
fi fi
rm ~/Dockerfile
fi fi
if [[ -f ~/.immich_library_revisions ]]; then if [[ -f ~/.immich_library_revisions ]]; then
curl -fsSLO https://raw.githubusercontent.com/immich-app/base-images/refs/heads/main/server/bin/build-lock.json curl -fsSLO https://raw.githubusercontent.com/immich-app/base-images/refs/heads/main/server/bin/build-lock.json
jq -cr '.sources[].revision' ./build-lock.json >~/.new_revisions jq -cr '.sources[].revision' ./build-lock.json >~/.new_revisions
readarray UPDATED_REVISIONS <<<"$(diff --unchanged-line-format= --old-line-format= --new-line-format='%L' ~/.immich_library_revisions ~/.new_revisions)" readarray -t UPDATED_REVISIONS <<<"$(diff --unchanged-line-format= --old-line-format= --new-line-format='%L' ~/.immich_library_revisions ~/.new_revisions)"
if [[ "$(echo "$UPDATED_REVISIONS" | wc -w)" -gt 0 ]]; then if [[ "$(echo "$UPDATED_REVISIONS" | wc -w)" -gt 0 ]]; then
readarray NAMES <<<"$(for revision in "${UPDATED_REVISIONS[@]}"; do readarray -t NAMES <<<"$(for revision in "${UPDATED_REVISIONS[@]}"; do
jq -cr --arg jq_revision $revision '.sources[] | select(.revision == $jq_revision).name' ./build-lock.json jq -cr --arg jq_revision $revision '.sources[] | select(.revision == $jq_revision).name' ./build-lock.json
done)" done)"
msg_info "Recompiling image-processing libraries (patience)" msg_info "Recompiling image-processing libraries (patience)"
@ -65,13 +66,13 @@ function update_script() {
JPEGLI_LIBJPEG_LIBRARY_VERSION="62.3.0" JPEGLI_LIBJPEG_LIBRARY_VERSION="62.3.0"
: "${LIBJXL_REVISION:=$(jq -cr '.sources[] | select(.name == "libjxl").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBJXL_REVISION:=$(jq -cr '.sources[] | select(.name == "libjxl").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libjxl/libjxl.git "$SOURCE" $STD git clone https://github.com/libjxl/libjxl.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBJXL_REVISION" $STD git reset --hard "$LIBJXL_REVISION"
$STD git submodule update --init --recursive --depth 1 --recommend-shallow $STD git submodule update --init --recursive --depth 1 --recommend-shallow
$STD git apply "$BASE_DIR"/server/bin/patches/jpegli-empty-dht-marker.patch $STD git apply "$BASE_DIR"/server/bin/patches/jpegli-empty-dht-marker.patch
$STD git apply "$BASE_DIR"/server/bin/patches/jpegli-icc-warning.patch $STD git apply "$BASE_DIR"/server/bin/patches/jpegli-icc-warning.patch
mkdir build mkdir build
cd build || exit cd build
$STD cmake \ $STD cmake \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \ -DBUILD_TESTING=OFF \
@ -94,17 +95,17 @@ function update_script() {
$STD cmake --install . $STD cmake --install .
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
rm -rf "$SOURCE"/{build,third_party} rm -rf "$SOURCE"/{build,third_party}
fi fi
if [[ "$name" == "libheif" ]]; then if [[ "$name" == "libheif" ]]; then
SOURCE=${SOURCE_DIR}/libheif SOURCE=${SOURCE_DIR}/libheif
: "${LIBHEIF_REVISION:=$(jq -cr '.sources[] | select(.name == "libheif").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBHEIF_REVISION:=$(jq -cr '.sources[] | select(.name == "libheif").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/strukturag/libheif.git "$SOURCE" $STD git clone https://github.com/strukturag/libheif.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBHEIF_REVISION" $STD git reset --hard "$LIBHEIF_REVISION"
mkdir build mkdir build
cd build || exit cd build
$STD cmake --preset=release-noplugins \ $STD cmake --preset=release-noplugins \
-DWITH_DAV1D=ON \ -DWITH_DAV1D=ON \
-DENABLE_PARALLEL_TILE_DECODING=ON \ -DENABLE_PARALLEL_TILE_DECODING=ON \
@ -118,14 +119,14 @@ function update_script() {
$STD make install -j "$(nproc)" $STD make install -j "$(nproc)"
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
rm -rf "$SOURCE"/build rm -rf "$SOURCE"/build
fi fi
if [[ "$name" == "libraw" ]]; then if [[ "$name" == "libraw" ]]; then
SOURCE=${SOURCE_DIR}/libraw SOURCE=${SOURCE_DIR}/libraw
: "${LIBRAW_REVISION:=$(jq -cr '.sources[] | select(.name == "libraw").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBRAW_REVISION:=$(jq -cr '.sources[] | select(.name == "libraw").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libraw/libraw.git "$SOURCE" $STD git clone https://github.com/libraw/libraw.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBRAW_REVISION" $STD git reset --hard "$LIBRAW_REVISION"
$STD autoreconf --install $STD autoreconf --install
$STD ./configure $STD ./configure
@ -133,37 +134,38 @@ function update_script() {
$STD make install $STD make install
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
fi fi
if [[ "$name" == "imagemagick" ]]; then if [[ "$name" == "imagemagick" ]]; then
SOURCE=$SOURCE_DIR/imagemagick SOURCE=$SOURCE_DIR/imagemagick
: "${IMAGEMAGICK_REVISION:=$(jq -cr '.sources[] | select(.name == "imagemagick").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${IMAGEMAGICK_REVISION:=$(jq -cr '.sources[] | select(.name == "imagemagick").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/ImageMagick/ImageMagick.git "$SOURCE" $STD git clone https://github.com/ImageMagick/ImageMagick.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$IMAGEMAGICK_REVISION" $STD git reset --hard "$IMAGEMAGICK_REVISION"
$STD ./configure --with-modules $STD ./configure --with-modules
$STD make -j"$(nproc)" $STD make -j"$(nproc)"
$STD make install $STD make install
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
fi fi
if [[ "$name" == "libvips" ]]; then if [[ "$name" == "libvips" ]]; then
SOURCE=$SOURCE_DIR/libvips SOURCE=$SOURCE_DIR/libvips
: "${LIBVIPS_REVISION:=$(jq -cr '.sources[] | select(.name == "libvips").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBVIPS_REVISION:=$(jq -cr '.sources[] | select(.name == "libvips").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libvips/libvips.git "$SOURCE" $STD git clone https://github.com/libvips/libvips.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBVIPS_REVISION" $STD git reset --hard "$LIBVIPS_REVISION"
$STD meson setup build --buildtype=release --libdir=lib -Dintrospection=disabled -Dtiff=disabled $STD meson setup build --buildtype=release --libdir=lib -Dintrospection=disabled -Dtiff=disabled
cd build || exit cd build
$STD ninja install $STD ninja install
ldconfig /usr/local/lib ldconfig /usr/local/lib
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
rm -rf "$SOURCE"/build rm -rf "$SOURCE"/build
fi fi
done done
mv ~/.new_revisions ~/.immich_library_revisions mv ~/.new_revisions ~/.immich_library_revisions
msg_done "Image-processing libraries compiled" rm ~/build-lock.json
msg_ok "Image-processing libraries compiled"
fi fi
fi fi
RELEASE=$(curl -s https://api.github.com/repos/immich-app/immich/releases?per_page=1 | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') RELEASE=$(curl -s https://api.github.com/repos/immich-app/immich/releases?per_page=1 | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
@ -177,7 +179,6 @@ function update_script() {
SRC_DIR="${INSTALL_DIR}/source" SRC_DIR="${INSTALL_DIR}/source"
APP_DIR="${INSTALL_DIR}/app" APP_DIR="${INSTALL_DIR}/app"
ML_DIR="${APP_DIR}/machine-learning" ML_DIR="${APP_DIR}/machine-learning"
GEO_DIR="${INSTALL_DIR}/geodata"
rm -rf "${APP_DIR:?}"/* rm -rf "${APP_DIR:?}"/*
rm -rf "$SRC_DIR" rm -rf "$SRC_DIR"
immich_zip=$(mktemp) immich_zip=$(mktemp)
@ -186,25 +187,25 @@ function update_script() {
unzip -q "$immich_zip" unzip -q "$immich_zip"
mv "$APP-$RELEASE"/ "$SRC_DIR" mv "$APP-$RELEASE"/ "$SRC_DIR"
mkdir -p "$ML_DIR" mkdir -p "$ML_DIR"
cd "$SRC_DIR"/server || exit cd "$SRC_DIR"/server
$STD npm install -g node-gyp node-pre-gyp $STD npm install -g node-gyp node-pre-gyp
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
$STD npm prune --omit=dev --omit=optional $STD npm prune --omit=dev --omit=optional
cd "$SRC_DIR"/open-api/typescript-sdk || exit cd "$SRC_DIR"/open-api/typescript-sdk
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
cd "$SRC_DIR"/web || exit cd "$SRC_DIR"/web
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
cd "$SRC_DIR" || exit cd "$SRC_DIR"
cp -a server/{node_modules,dist,bin,resources,package.json,package-lock.json,start*.sh} "$APP_DIR"/ cp -a server/{node_modules,dist,bin,resources,package.json,package-lock.json,start*.sh} "$APP_DIR"/
cp -a web/build "$APP_DIR"/www cp -a web/build "$APP_DIR"/www
cp LICENSE "$APP_DIR" cp LICENSE "$APP_DIR"
cp "$BASE_DIR"/server/bin/build-lock.json "$APP_DIR" cp "$BASE_DIR"/server/bin/build-lock.json "$APP_DIR"
msg_ok "Updated ${APP} web and microservices" msg_ok "Updated ${APP} web and microservices"
cd "$SRC_DIR"/machine-learning || exit cd "$SRC_DIR"/machine-learning
if [[ -f ~/.openvino ]]; then if [[ -f ~/.openvino ]]; then
msg_info "Updating HW-accelerated machine-learning" msg_info "Updating HW-accelerated machine-learning"
( (
@ -223,13 +224,13 @@ function update_script() {
) )
msg_ok "Updated machine-learning" msg_ok "Updated machine-learning"
fi fi
cd "$SRC_DIR" || exit cd "$SRC_DIR"
cp -a machine-learning/{ann,immich_ml} "$ML_DIR" cp -a machine-learning/{ann,immich_ml} "$ML_DIR"
if [[ -f ~/.openvino ]]; then if [[ -f ~/.openvino ]]; then
sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py
fi fi
ln -sf "$APP_DIR"/resources "$INSTALL_DIR" ln -sf "$APP_DIR"/resources "$INSTALL_DIR"
cd "$APP_DIR" || exit cd "$APP_DIR"
grep -Rl /usr/src | xargs -n1 sed -i "s|\/usr/src|$INSTALL_DIR|g" grep -Rl /usr/src | xargs -n1 sed -i "s|\/usr/src|$INSTALL_DIR|g"
grep -RlE "'/build'" | xargs -n1 sed -i "s|'/build'|'$APP_DIR'|g" grep -RlE "'/build'" | xargs -n1 sed -i "s|'/build'|'$APP_DIR'|g"
sed -i "s@\"/cache\"@\"$INSTALL_DIR/cache\"@g" "$ML_DIR"/immich_ml/config.py sed -i "s@\"/cache\"@\"$INSTALL_DIR/cache\"@g" "$ML_DIR"/immich_ml/config.py

View File

@ -157,7 +157,7 @@ $STD apt-get install -t testing --no-install-recommends -y \
libdav1d-dev \ libdav1d-dev \
libhwy-dev \ libhwy-dev \
libwebp-dev libwebp-dev
if [[ "$intel_hw" = 1 ]]; then if [[ -f ~/.openvino ]]; then
$STD apt-get install -t testing -y patchelf $STD apt-get install -t testing -y patchelf
fi fi
msg_ok "Packages from Testing Repo Installed" msg_ok "Packages from Testing Repo Installed"
@ -176,19 +176,19 @@ SOURCE_DIR=${STAGING_DIR}/image-source
$STD git clone -b main "$BASE_REPO" "$BASE_DIR" $STD git clone -b main "$BASE_REPO" "$BASE_DIR"
mkdir -p "$SOURCE_DIR" mkdir -p "$SOURCE_DIR"
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
SOURCE=${SOURCE_DIR}/libjxl SOURCE=${SOURCE_DIR}/libjxl
JPEGLI_LIBJPEG_LIBRARY_SOVERSION="62" JPEGLI_LIBJPEG_LIBRARY_SOVERSION="62"
JPEGLI_LIBJPEG_LIBRARY_VERSION="62.3.0" JPEGLI_LIBJPEG_LIBRARY_VERSION="62.3.0"
: "${LIBJXL_REVISION:=$(jq -cr '.sources[] | select(.name == "libjxl").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBJXL_REVISION:=$(jq -cr '.sources[] | select(.name == "libjxl").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libjxl/libjxl.git "$SOURCE" $STD git clone https://github.com/libjxl/libjxl.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBJXL_REVISION" $STD git reset --hard "$LIBJXL_REVISION"
$STD git submodule update --init --recursive --depth 1 --recommend-shallow $STD git submodule update --init --recursive --depth 1 --recommend-shallow
$STD git apply "$BASE_DIR"/server/bin/patches/jpegli-empty-dht-marker.patch $STD git apply "$BASE_DIR"/server/bin/patches/jpegli-empty-dht-marker.patch
$STD git apply "$BASE_DIR"/server/bin/patches/jpegli-icc-warning.patch $STD git apply "$BASE_DIR"/server/bin/patches/jpegli-icc-warning.patch
mkdir build mkdir build
cd build || exit cd build
$STD cmake \ $STD cmake \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \ -DBUILD_TESTING=OFF \
@ -211,16 +211,16 @@ $STD cmake --build . -- -j"$(nproc)"
$STD cmake --install . $STD cmake --install .
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
rm -rf "$SOURCE"/{build,third_party} rm -rf "$SOURCE"/{build,third_party}
SOURCE=${SOURCE_DIR}/libheif SOURCE=${SOURCE_DIR}/libheif
: "${LIBHEIF_REVISION:=$(jq -cr '.sources[] | select(.name == "libheif").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBHEIF_REVISION:=$(jq -cr '.sources[] | select(.name == "libheif").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/strukturag/libheif.git "$SOURCE" $STD git clone https://github.com/strukturag/libheif.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBHEIF_REVISION" $STD git reset --hard "$LIBHEIF_REVISION"
mkdir build mkdir build
cd build || exit cd build
$STD cmake --preset=release-noplugins \ $STD cmake --preset=release-noplugins \
-DWITH_DAV1D=ON \ -DWITH_DAV1D=ON \
-DENABLE_PARALLEL_TILE_DECODING=ON \ -DENABLE_PARALLEL_TILE_DECODING=ON \
@ -234,13 +234,13 @@ $STD cmake --preset=release-noplugins \
$STD make install -j "$(nproc)" $STD make install -j "$(nproc)"
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
rm -rf "$SOURCE"/build rm -rf "$SOURCE"/build
SOURCE=${SOURCE_DIR}/libraw SOURCE=${SOURCE_DIR}/libraw
: "${LIBRAW_REVISION:=$(jq -cr '.sources[] | select(.name == "libraw").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBRAW_REVISION:=$(jq -cr '.sources[] | select(.name == "libraw").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libraw/libraw.git "$SOURCE" $STD git clone https://github.com/libraw/libraw.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBRAW_REVISION" $STD git reset --hard "$LIBRAW_REVISION"
$STD autoreconf --install $STD autoreconf --install
$STD ./configure $STD ./configure
@ -248,30 +248,30 @@ $STD make -j"$(nproc)"
$STD make install $STD make install
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
SOURCE=$SOURCE_DIR/imagemagick SOURCE=$SOURCE_DIR/imagemagick
: "${IMAGEMAGICK_REVISION:=$(jq -cr '.sources[] | select(.name == "imagemagick").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${IMAGEMAGICK_REVISION:=$(jq -cr '.sources[] | select(.name == "imagemagick").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/ImageMagick/ImageMagick.git "$SOURCE" $STD git clone https://github.com/ImageMagick/ImageMagick.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$IMAGEMAGICK_REVISION" $STD git reset --hard "$IMAGEMAGICK_REVISION"
$STD ./configure --with-modules $STD ./configure --with-modules
$STD make -j"$(nproc)" $STD make -j"$(nproc)"
$STD make install $STD make install
ldconfig /usr/local/lib ldconfig /usr/local/lib
$STD make clean $STD make clean
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
SOURCE=$SOURCE_DIR/libvips SOURCE=$SOURCE_DIR/libvips
: "${LIBVIPS_REVISION:=$(jq -cr '.sources[] | select(.name == "libvips").revision' $BASE_DIR/server/bin/build-lock.json)}" : "${LIBVIPS_REVISION:=$(jq -cr '.sources[] | select(.name == "libvips").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libvips/libvips.git "$SOURCE" $STD git clone https://github.com/libvips/libvips.git "$SOURCE"
cd "$SOURCE" || exit cd "$SOURCE"
$STD git reset --hard "$LIBVIPS_REVISION" $STD git reset --hard "$LIBVIPS_REVISION"
$STD meson setup build --buildtype=release --libdir=lib -Dintrospection=disabled -Dtiff=disabled $STD meson setup build --buildtype=release --libdir=lib -Dintrospection=disabled -Dtiff=disabled
cd build || exit cd build
$STD ninja install $STD ninja install
ldconfig /usr/local/lib ldconfig /usr/local/lib
cd "$STAGING_DIR" || exit cd "$STAGING_DIR"
rm -rf "$SOURCE"/build rm -rf "$SOURCE"/build
{ {
echo "$IMAGEMAGICK_REVISION" echo "$IMAGEMAGICK_REVISION"
@ -297,25 +297,25 @@ mkdir -p "$INSTALL_DIR"
mv "$APPLICATION-$RELEASE"/ "$SRC_DIR" mv "$APPLICATION-$RELEASE"/ "$SRC_DIR"
mkdir -p {"${APP_DIR}","${UPLOAD_DIR}","${GEO_DIR}","${ML_DIR}","${INSTALL_DIR}"/cache} mkdir -p {"${APP_DIR}","${UPLOAD_DIR}","${GEO_DIR}","${ML_DIR}","${INSTALL_DIR}"/cache}
cd "$SRC_DIR"/server || exit cd "$SRC_DIR"/server
$STD npm install -g node-gyp node-pre-gyp $STD npm install -g node-gyp node-pre-gyp
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
$STD npm prune --omit=dev --omit=optional $STD npm prune --omit=dev --omit=optional
cd "$SRC_DIR"/open-api/typescript-sdk || exit cd "$SRC_DIR"/open-api/typescript-sdk
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
cd "$SRC_DIR"/web || exit cd "$SRC_DIR"/web
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
cd "$SRC_DIR" || exit cd "$SRC_DIR"
cp -a server/{node_modules,dist,bin,resources,package.json,package-lock.json,start*.sh} "$APP_DIR"/ cp -a server/{node_modules,dist,bin,resources,package.json,package-lock.json,start*.sh} "$APP_DIR"/
cp -a web/build "$APP_DIR"/www cp -a web/build "$APP_DIR"/www
cp LICENSE "$APP_DIR" cp LICENSE "$APP_DIR"
cp "$BASE_DIR"/server/bin/build-lock.json "$APP_DIR" cp "$BASE_DIR"/server/bin/build-lock.json "$APP_DIR"
msg_ok "Installed Immich Web Components" msg_ok "Installed Immich Web Components"
cd "$SRC_DIR"/machine-learning || exit cd "$SRC_DIR"/machine-learning
$STD python3 -m venv "$ML_DIR/ml-venv" $STD python3 -m venv "$ML_DIR/ml-venv"
if [[ -f ~/.openvino ]]; then if [[ -f ~/.openvino ]]; then
msg_info "Installing HW-accelerated machine-learning" msg_info "Installing HW-accelerated machine-learning"
@ -335,14 +335,14 @@ else
) )
msg_ok "Installed machine-learning" msg_ok "Installed machine-learning"
fi fi
cd "$SRC_DIR" || exit cd "$SRC_DIR"
cp -a machine-learning/{ann,immich_ml} "$ML_DIR" cp -a machine-learning/{ann,immich_ml} "$ML_DIR"
if [[ "$intel_hw" = 1 ]]; then if [[ -f ~/.openvino ]]; then
sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py
fi fi
ln -sf "$APP_DIR"/resources "$INSTALL_DIR" ln -sf "$APP_DIR"/resources "$INSTALL_DIR"
cd "$APP_DIR" || exit cd "$APP_DIR"
grep -Rl /usr/src | xargs -n1 sed -i "s|\/usr/src|$INSTALL_DIR|g" grep -Rl /usr/src | xargs -n1 sed -i "s|\/usr/src|$INSTALL_DIR|g"
grep -RlE "'/build'" | xargs -n1 sed -i "s|'/build'|'$APP_DIR'|g" grep -RlE "'/build'" | xargs -n1 sed -i "s|'/build'|'$APP_DIR'|g"
sed -i "s@\"/cache\"@\"$INSTALL_DIR/cache\"@g" "$ML_DIR"/immich_ml/config.py sed -i "s@\"/cache\"@\"$INSTALL_DIR/cache\"@g" "$ML_DIR"/immich_ml/config.py
@ -356,7 +356,7 @@ $STD npm i -g @immich/cli
msg_ok "Installed Immich CLI" msg_ok "Installed Immich CLI"
msg_info "Installing GeoNames data" msg_info "Installing GeoNames data"
cd "$GEO_DIR" || exit cd "$GEO_DIR"
URL_LIST=( URL_LIST=(
https://download.geonames.org/export/dump/admin1CodesASCII.txt https://download.geonames.org/export/dump/admin1CodesASCII.txt
https://download.geonames.org/export/dump/admin2Codes.txt https://download.geonames.org/export/dump/admin2Codes.txt
@ -367,7 +367,7 @@ echo "${URL_LIST[@]}" | xargs -n1 -P 8 wget -q
unzip -q cities500.zip unzip -q cities500.zip
date --iso-8601=seconds | tr -d "\n" >geodata-date.txt date --iso-8601=seconds | tr -d "\n" >geodata-date.txt
rm cities500.zip rm cities500.zip
cd "$INSTALL_DIR" || exit cd "$INSTALL_DIR"
ln -s "$GEO_DIR" "$APP_DIR" ln -s "$GEO_DIR" "$APP_DIR"
msg_ok "Installed GeoNames data" msg_ok "Installed GeoNames data"
@ -378,7 +378,7 @@ msg_ok "Installed ${APPLICATION}"
msg_info "Creating user, env file, scripts & services" msg_info "Creating user, env file, scripts & services"
$STD useradd -U -s /usr/sbin/nologin -r -M -d "$INSTALL_DIR" immich $STD useradd -U -s /usr/sbin/nologin -r -M -d "$INSTALL_DIR" immich
if [[ "$intel_hw" = 1 ]]; then if [[ -f ~/.openvino ]]; then
usermod -aG video,render immich usermod -aG video,render immich
fi fi
cat <<EOF >"${INSTALL_DIR}"/.env cat <<EOF >"${INSTALL_DIR}"/.env