From 53bc45342f713e5583e69e6a6f5988c4522b1c0a Mon Sep 17 00:00:00 2001 From: Sylvain Date: Fri, 14 Jun 2024 13:59:30 +0200 Subject: [PATCH] Fix breaking changes --- conf/env-machine-learning | 11 ++++++ conf/{env => env-server} | 6 +-- conf/immich-machine-learning-start.sh | 8 ++-- conf/immich-machine-learning.service | 2 +- conf/immich-microservices.service | 54 --------------------------- conf/immich-server-start.sh | 2 +- conf/immich-server.service | 3 +- doc/PRE_INSTALL.md | 3 +- doc/PRE_INSTALL_fr.md | 3 +- manifest.toml | 1 - scripts/_common.sh | 5 +-- scripts/backup | 1 - scripts/change_url | 2 - scripts/install | 13 ++++--- scripts/remove | 4 -- scripts/restore | 4 -- scripts/upgrade | 28 +++++++++----- 17 files changed, 52 insertions(+), 98 deletions(-) create mode 100644 conf/env-machine-learning rename conf/{env => env-server} (75%) delete mode 100644 conf/immich-microservices.service diff --git a/conf/env-machine-learning b/conf/env-machine-learning new file mode 100644 index 0000000..f55dbf4 --- /dev/null +++ b/conf/env-machine-learning @@ -0,0 +1,11 @@ +## Ports +IMMICH_HOST=127.0.0.1 +IMMICH_PORT=__PORT_MACHINELEARNING__ + +## Database +DB_HOSTNAME=127.0.0.1 +DB_PORT=__DB_PORT__ +DB_USERNAME=__APP__ +DB_PASSWORD=__DB_PWD__ +DB_DATABASE_NAME=__APP__ +DB_VECTOR_EXTENSION=pgvector diff --git a/conf/env b/conf/env-server similarity index 75% rename from conf/env rename to conf/env-server index ec41098..7d8e386 100644 --- a/conf/env +++ b/conf/env-server @@ -5,10 +5,8 @@ IMMICH_WEB_ROOT=__INSTALL_DIR__/app/www IMMICH_REVERSE_GEOCODING_ROOT=__INSTALL_DIR__/app/resources ## Ports -SERVER_PORT=__PORT__ -MICROSERVICES_PORT=__PORT_MICROSERVICES__ -MACHINE_LEARNING_HOST=127.0.0.1 -MACHINE_LEARNING_PORT=__PORT_MACHINELEARNING__ +IMMICH_HOST=127.0.0.1 +IMMICH_PORT=__PORT__ IMMICH_MACHINE_LEARNING_URL=http://127.0.0.1:__PORT_MACHINELEARNING__ ## Database diff --git a/conf/immich-machine-learning-start.sh b/conf/immich-machine-learning-start.sh index 20443e2..58b18af 100644 --- a/conf/immich-machine-learning-start.sh +++ b/conf/immich-machine-learning-start.sh @@ -1,21 +1,21 @@ #!/bin/bash set -a -source "__INSTALL_DIR__/env" +source "__INSTALL_DIR__/env-machine-learning" set +a cd "__INSTALL_DIR__/app/machine-learning" source venv/bin/activate -: "${MACHINE_LEARNING_HOST:=127.0.0.1}" -: "${MACHINE_LEARNING_PORT:=__PORT_MACHINELEARNING__}" +: "${IMMICH_HOST:=127.0.0.1}" +: "${IMMICH_PORT:=__PORT_MACHINELEARNING__}" : "${MACHINE_LEARNING_WORKERS:=1}" : "${MACHINE_LEARNING_WORKER_TIMEOUT:=120}" exec gunicorn app.main:app \ -k app.config.CustomUvicornWorker \ + -b "$IMMICH_HOST":"$IMMICH_PORT" \ -w "$MACHINE_LEARNING_WORKERS" \ - -b "$MACHINE_LEARNING_HOST":"$MACHINE_LEARNING_PORT" \ -t "$MACHINE_LEARNING_WORKER_TIMEOUT" \ --log-config-json log_conf.json \ --graceful-timeout 0 diff --git a/conf/immich-machine-learning.service b/conf/immich-machine-learning.service index c4002b6..5ba378a 100644 --- a/conf/immich-machine-learning.service +++ b/conf/immich-machine-learning.service @@ -11,7 +11,7 @@ Restart=on-failure User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/app -EnvironmentFile=__INSTALL_DIR__/env +EnvironmentFile=__INSTALL_DIR__/env-machine-learning ExecStart=__INSTALL_DIR__/app/machine-learning/start.sh StandardOutput=append:/var/log/__APP__/__APP__-machine-learning.log StandardError=inherit diff --git a/conf/immich-microservices.service b/conf/immich-microservices.service deleted file mode 100644 index dce2408..0000000 --- a/conf/immich-microservices.service +++ /dev/null @@ -1,54 +0,0 @@ -[Unit] -Description=Immich microservices -Documentation=https://github.com/immich-app/immich -Requires=redis-server.service -Requires=postgresql.service -After=network.target -PartOf=immich-server.service -Before=immich-server.service - -[Service] -Type=simple -Restart=on-failure -User=__APP__ -Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/app -Environment="__YNH_NODE_LOAD_PATH__" -EnvironmentFile=__INSTALL_DIR__/env -ExecStart=__YNH_NODE__ __INSTALL_DIR__/app/dist/main microservices -StandardOutput=append:/var/log/__APP__/__APP__-microservices.log -StandardError=inherit -Restart=on-failure - -# Sandboxing options to harden security -# Depending on specificities of your service/app, you may need to tweak these -# .. but this should be a good baseline -# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html -NoNewPrivileges=yes -PrivateTmp=yes -PrivateDevices=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 -RestrictNamespaces=yes -RestrictRealtime=yes -DevicePolicy=closed -ProtectSystem=full -ProtectControlGroups=yes -ProtectKernelModules=yes -ProtectKernelTunables=yes -LockPersonality=yes -SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap - -# Denying access to capabilities that should not be relevant for webapps -# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html -CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD -CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE -CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT -CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK -CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM -CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG -CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE -CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW -CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG - -[Install] -WantedBy=immich-server.service diff --git a/conf/immich-server-start.sh b/conf/immich-server-start.sh index 77ddfd6..b97540d 100644 --- a/conf/immich-server-start.sh +++ b/conf/immich-server-start.sh @@ -1,7 +1,7 @@ #!/bin/bash set -a -. "__INSTALL_DIR__/env" +. "__INSTALL_DIR__/env-server" set +a cd "__INSTALL_DIR__/app" diff --git a/conf/immich-server.service b/conf/immich-server.service index f59f140..ef6a067 100644 --- a/conf/immich-server.service +++ b/conf/immich-server.service @@ -4,7 +4,6 @@ Documentation=https://github.com/immich-app/immich Requires=redis-server.service Requires=postgresql.service Requires=immich-machine-learning.service -Requires=immich-microservices.service After=network.target [Service] @@ -14,7 +13,7 @@ User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/app Environment="__YNH_NODE_LOAD_PATH__" -EnvironmentFile=__INSTALL_DIR__/env +EnvironmentFile=__INSTALL_DIR__/env-server ExecStart=__YNH_NODE__ __INSTALL_DIR__/app/dist/main __APP__ StandardOutput=append:/var/log/__APP__/__APP__-server.log StandardError=inherit diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md index 6ee38c0..33bd440 100644 --- a/doc/PRE_INSTALL.md +++ b/doc/PRE_INSTALL.md @@ -1,5 +1,6 @@ As the pyhton version shipped in Debian stable is not always supported, a recent version could be built during the installation process. It may take a while to achieve that (15 to 60 minutes). This package provides support for the JPEG, PNG, WebP, AVIF (limited to 8-bit depth), TIFF, GIF and SVG (input) image formats. -HEIC/HEIF file format is not supported (see cf. https://github.com/YunoHost-Apps/immich_ynh/issues/40#issuecomment-2096788600). +**HEIC/HEIF file format is not supported** (see cf. https://github.com/YunoHost-Apps/immich_ynh/issues/40#issuecomment-2096788600). +Please ensure **your mobile app and server are on the same version**. Otherwise, you won't be able to access the app. diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md index e84d241..ae6a9b3 100644 --- a/doc/PRE_INSTALL_fr.md +++ b/doc/PRE_INSTALL_fr.md @@ -1,5 +1,6 @@ Comme la version python livrée dans Debian stable n'est pas toujours prise en charge, une version récente pourrait être construite pendant le processus d'installation. Cela peut prendre un certain temps pour y parvenir (15 à 60 minutes). Ce package supporte les formats d'images suivant : JPEG, PNG, WebP, AVIF (limité à profondeur de couleur de 8 bits), TIFF, GIF et SVG. -Le format HEIC/HEIF n'est pas supporté (cf. https://github.com/YunoHost-Apps/immich_ynh/issues/40#issuecomment-2096788600). +**Le format HEIC/HEIF n'est pas supporté** (cf. https://github.com/YunoHost-Apps/immich_ynh/issues/40#issuecomment-2096788600). +Assurez-vous que **l'application mobile et le serveur sont sur la même version**. Dans le cas contraire vous risquez de ne pas pouvoir accèder à l'application. diff --git a/manifest.toml b/manifest.toml index 2b6e376..d011db8 100644 --- a/manifest.toml +++ b/manifest.toml @@ -49,7 +49,6 @@ ram.runtime = "500M" [resources.ports] main.default = 3001 - microservices.default = 3002 machinelearning.default = 3003 [resources.system_user] diff --git a/scripts/_common.sh b/scripts/_common.sh index 05d7687..8874fc8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -145,8 +145,7 @@ myynh_install_immich() { cp -a "$source_dir/server/resources" "$install_dir/app/" cp -a "$source_dir/server/package.json" "$install_dir/app/" cp -a "$source_dir/server/package-lock.json" "$install_dir/app/" - cp -a "$source_dir/server/start-microservices.sh" "$install_dir/app/" - cp -a "$source_dir/server/start-server.sh" "$install_dir/app/" + cp -a "$source_dir/server/start*.sh" "$install_dir/app/" cp -a "$source_dir/LICENSE" "$install_dir/app/" # Install custom start.sh script ynh_add_config --template="immich-server-start.sh" --destination="$install_dir/app/start.sh" @@ -187,7 +186,7 @@ myynh_install_immich() { cd "$install_dir/app" ynh_exec_warn_less "$ynh_npm" install sharp - # Use 127.0.0.1 for microservices + # Use 127.0.0.1 sed -i -e "s@app.listen(port)@app.listen(port, '127.0.0.1')@g" "$install_dir/app/dist/main.js" # Install geonames diff --git a/scripts/backup b/scripts/backup index 016ed91..c6814b6 100755 --- a/scripts/backup +++ b/scripts/backup @@ -28,7 +28,6 @@ ynh_backup --src_path="$data_dir" --is_big ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app-server.service" -ynh_backup --src_path="/etc/systemd/system/$app-microservices.service" ynh_backup --src_path="/etc/systemd/system/$app-machine-learning.service" ynh_backup --src_path="/etc/logrotate.d/$app" diff --git a/scripts/change_url b/scripts/change_url index 8a127a8..2a06284 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,7 +11,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 -ynh_systemd_action --service_name="$app-microservices" --action="stop" --log_path="/var/log/$app/$app-microservices.log" ynh_systemd_action --service_name="$app-machine-learning" --action="stop" --log_path="/var/log/$app/$app-machine-learning.log" ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/$app-server.log" @@ -31,7 +30,6 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name="$app-microservices" --action="start" --line_match="Immich Microservices is listening" --log_path="/var/log/$app/$app-microservices.log" ynh_systemd_action --service_name="$app-machine-learning" --action="start" --line_match="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log" ynh_systemd_action --service_name="$app-server" --action="start" --line_match="Immich Server is listening" --log_path="/var/log/$app/$app-server.log" diff --git a/scripts/install b/scripts/install index 8ce42da..9484993 100755 --- a/scripts/install +++ b/scripts/install @@ -56,9 +56,13 @@ myynh_install_immich #================================================= ynh_script_progression --message="Adding a configuration file..." -ynh_add_config --template="env" --destination="$install_dir/env" -chmod 600 "$install_dir/env" -chown $app:$app "$install_dir/env" +ynh_add_config --template="env-server" --destination="$install_dir/env-server" +chmod 600 "$install_dir/env-server" +chown $app:$app "$install_dir/env-server" + +ynh_add_config --template="env-machine-learning" --destination="$install_dir/env-machine-learning" +chmod 600 "$install_dir/env-machine-learning" +chown $app:$app "$install_dir/env-machine-learning" #================================================= # SYSTEM CONFIGURATION @@ -68,11 +72,9 @@ ynh_script_progression --message="Adding system configurations related to $app.. ynh_add_nginx_config ynh_add_systemd_config --service="$app-server" --template="immich-server.service" -ynh_add_systemd_config --service="$app-microservices" --template="immich-microservices.service" ynh_add_systemd_config --service="$app-machine-learning" --template="immich-machine-learning.service" yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log" -yunohost service add "$app-microservices" --description="Immich Microservices" --log="/var/log/$app/$app-microservices.log" yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log" ynh_multimedia_build_main_dir @@ -87,7 +89,6 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/$app-server.log" --failregex="$ #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name="$app-microservices" --action="start" --line_match="Immich Microservices is listening" --log_path="/var/log/$app/$app-microservices.log" ynh_systemd_action --service_name="$app-machine-learning" --action="start" --line_match="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log" ynh_systemd_action --service_name="$app-server" --action="start" --line_match="Immich Server is listening" --log_path="/var/log/$app/$app-server.log" diff --git a/scripts/remove b/scripts/remove index 770c186..231ca12 100755 --- a/scripts/remove +++ b/scripts/remove @@ -15,16 +15,12 @@ ynh_script_progression --message="Removing system configurations related to $app if ynh_exec_warn_less yunohost service status "$app-server" >/dev/null; then yunohost service remove "$app-server" fi -if ynh_exec_warn_less yunohost service status "$app-microservices" >/dev/null; then - yunohost service remove "$app-microservices" -fi if ynh_exec_warn_less yunohost service status "$app-machine-learning" >/dev/null; then yunohost service remove "$app-machine-learning" fi # Remove the dedicated systemd config ynh_remove_systemd_config --service="immich-server" -ynh_remove_systemd_config --service="immich-microservices" ynh_remove_systemd_config --service="immich-machine-learning" # Remove the app-specific fail2ban config diff --git a/scripts/restore b/scripts/restore index a268b3f..c82f41d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -59,15 +59,12 @@ ynh_script_progression --message="Restoring system configurations related to $ap ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app-server.service" -ynh_restore_file --origin_path="/etc/systemd/system/$app-microservices.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-machine-learning.service" systemctl enable "$app-server.service" --quiet -systemctl enable "$app-microservices.service" --quiet systemctl enable "$app-machine-learning.service" --quiet yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log" -yunohost service add "$app-microservices" --description="Immich Microservices" --log="/var/log/$app/$app-microservices.log" yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log" ynh_multimedia_build_main_dir @@ -89,7 +86,6 @@ ynh_restore_file --origin_path="/var/log/$app/" #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name="$app-microservices" --action="start" --line_match="Immich Microservices is listening" --log_path="/var/log/$app/$app-microservices.log" ynh_systemd_action --service_name="$app-machine-learning" --action="start" --line_match="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log" ynh_systemd_action --service_name="$app-server" --action="start" --line_match="Immich Server is listening" --log_path="/var/log/$app/$app-server.log" diff --git a/scripts/upgrade b/scripts/upgrade index 1cdf14b..ffbbadd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,13 +12,22 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name="$app-server" --action="stop" -ynh_systemd_action --service_name="$app-microservices" --action="stop" ynh_systemd_action --service_name="$app-machine-learning" --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +if ynh_compare_current_package_version --comparison lt --version 1.106.4~ynh1 +then + ynh_systemd_action --service_name="$app-microservices" --action="stop" + if ynh_exec_warn_less yunohost service status "$app-microservices" >/dev/null; then + yunohost service remove "$app-microservices" + fi + ynh_remove_systemd_config --service="immich-microservices" + ynh_secure_remove --file="/var/log/$app/$app-microservices.log" +fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -59,9 +68,14 @@ ynh_script_progression --message="Updating $app's configuration files..." --weig db_pwd=$(ynh_app_setting_get --app="$app" --key=psql_pwd) db_port=$(ynh_app_setting_get --app="$app" --key=psql_port) -ynh_add_config --template="env" --destination="$install_dir/env" -chmod 600 "$install_dir/env" -chown $app:$app "$install_dir/env" + +ynh_add_config --template="env-server" --destination="$install_dir/env-server" +chmod 600 "$install_dir/env-server" +chown $app:$app "$install_dir/env-server" + +ynh_add_config --template="env-machine-learning" --destination="$install_dir/env-machine-learning" +chmod 600 "$install_dir/env-machine-learning" +chown $app:$app "$install_dir/env-machine-learning" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -71,10 +85,8 @@ ynh_script_progression --message="Upgrading system configurations related to $ap ynh_add_nginx_config ynh_add_systemd_config --service="$app-server" --template="immich-server.service" -ynh_add_systemd_config --service="$app-microservices" --template="immich-microservices.service" ynh_add_systemd_config --service="$app-machine-learning" --template="immich-machine-learning.service" -yunohost service add "$app-microservices" --description="Immich Microservices" --log="/var/log/$app/$app-microservices.log" yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log" yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log" @@ -89,8 +101,6 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/$app-server.log" --failregex="$ # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --service_name="$app-microservices" --action="start" --line_match="Immich Microservices is listening" --log_path="/var/log/$app/$app-microservices.log" ynh_systemd_action --service_name="$app-machine-learning" --action="start" --line_match="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log" ynh_systemd_action --service_name="$app-server" --action="start" --line_match="Immich Server is listening" --log_path="/var/log/$app/$app-server.log"