diff --git a/README.md b/README.md index 0a47745..a9967f2 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Umami is a simple, easy to use, self-hosted web analytics solution. The goal is - Privacy-focused -**Shipped version:** 2.8.0~ynh1 +**Shipped version:** 2.9.0~ynh1 **Demo:** https://app.umami.is/share/8rmHaheU/umami.is diff --git a/README_fr.md b/README_fr.md index 9cf1db7..d034adc 100644 --- a/README_fr.md +++ b/README_fr.md @@ -31,7 +31,7 @@ Umami is a simple, easy to use, self-hosted web analytics solution. The goal is - Privacy-focused -**Version incluse :** 2.8.0~ynh1 +**Version incluse :** 2.9.0~ynh1 **Démo :** https://app.umami.is/share/8rmHaheU/umami.is diff --git a/conf/.env b/conf/.env index 865c609..eabf6ea 100644 --- a/conf/.env +++ b/conf/.env @@ -3,3 +3,4 @@ DATABASE_URL=postgresql://__DB_USER__:__DB_PWD__@127.0.0.1:5432/__DB_NAME__ DISABLE_TELEMETRY=1 PORT=__PORT__ DEFAULT_LOCALE="__LANGUAGE__" +NODE_ENV=production diff --git a/conf/systemd.service b/conf/systemd.service index 7f6806e..15b2e0d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/ +WorkingDirectory=__INSTALL_DIR__/release Environment=NODE_ENV=production Environment="__YNH_NODE_LOAD_PATH__" Environment=NEXT_TELEMETRY_DISABLED=1 diff --git a/manifest.toml b/manifest.toml index 6a9366e..d35a60c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,9 +5,9 @@ name = "Umami" description.en = "Simple, fast, privacy-focused alternative to Google Analytics" description.fr = "Analyse de trafic web simple et respectueux" -version = "2.8.0~ynh1" +version = "2.9.0~ynh1" -maintainers = ["eric_G"] +maintainers = ["orhtej2"] [upstream] license = "MIT" @@ -47,8 +47,8 @@ ram.runtime = "50M" [resources.sources.main] - url = "https://github.com/mikecao/umami/archive/refs/tags/v2.8.0.tar.gz" - sha256 = "c12d698672952f20cbff63d73854e11ae68af4d14654cb6352702aa9ca0f9614" + url = "https://github.com/mikecao/umami/archive/refs/tags/v2.9.0.tar.gz" + sha256 = "42f1b7b85dc41b1300ad3b61bc0eda8eee82eb0ff414ab055f9057410b83bd93" autoupdate.strategy = "latest_github_tag" [resources.system_user] diff --git a/scripts/install b/scripts/install index 4beff87..2b136a6 100755 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_script_progression --message="Setting up source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/build" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -46,10 +46,10 @@ yunohost service add $app --description="Web Analytics" --log="/var/log/$app/$ap #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" +ynh_add_config --template="../conf/.env" --destination="$install_dir/build/.env" -chmod 650 "$install_dir/.env" -chown $app:$app "$install_dir/.env" +chmod 650 "$install_dir/build/.env" +chown $app:$app "$install_dir/build/.env" ynh_script_progression --message="Provisioning pgcrypto..." --weight=1 @@ -60,12 +60,34 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --data #================================================= ynh_script_progression --message="Configuring the app..." --weight=15 -pushd $install_dir +pushd "$install_dir/build" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NEXT_TELEMETRY_DISABLED=1 yarn build + + # Actual app is a subset of release assets + # List of deps based on Dockerfile: https://github.com/umami-software/umami/blob/master/Dockerfile + ynh_secure_remove --file="node_modules/" + mv next.config.js .next/standalone/ + mv public .next/standalone/ + mv prisma .next/standalone/ + mv scripts .next/standalone/ + mv .next/static .next/standalone/.next popd +mkdir "$install_dir/release" +chmod -R o-rwx "$install_dir/release" +chown -R $app:www-data "$install_dir/release" + +mv -f $install_dir/build/.next/standalone/* $install_dir/build/.next/standalone/.[!.]* $install_dir/release + +pushd "$install_dir/release" + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn add npm-run-all dotenv prisma +popd + +ynh_secure_remove --file="$install_dir/.cache" +ynh_secure_remove --file="$install_dir/build" + #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 17363d2..9f3a491 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -41,16 +41,25 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +if $(ynh_compare_current_package_version --comparison le --version "2.7.0~ynh4") then - ynh_script_progression --message="Upgrading source files..." --weight=5 - - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --full_replace=1 #--keep=".env" + # Purge old root directory's contents + ynh_script_progression --message="Removing old files..." --weight=2 + mkdir /tmp/release + chmod -R o-rwx /tmp/release + chown -R $app:www-data /tmp/release + mv -f $install_dir/* $install_dir/.[!.]* /tmp/release + mv /tmp/release $install_dir/ fi -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +if [[ "$upgrade_type" == "UPGRADE_APP" || $(ynh_compare_current_package_version --comparison le --version "2.7.0~ynh4") ]]; then + ynh_script_progression --message="Upgrading source files..." --weight=5 + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$install_dir/build" --full_replace=1 #--keep=".env" +fi + +chmod -R o-rwx "$install_dir/build" +chown -R $app:www-data "$install_dir/build" #================================================= # UPGRADE DEPENDENCIES @@ -78,10 +87,10 @@ yunohost service add $app --description="Web Analytics" --log="/var/log/$app/$ap #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" +ynh_add_config --template="../conf/.env" --destination="$install_dir/build/.env" -chmod 650 "$install_dir/.env" -chown $app:$app "$install_dir/.env" +chmod 650 "$install_dir/build/.env" +chown $app:$app "$install_dir/build/.env" ynh_script_progression --message="Provisioning pgcrypto..." --weight=1 @@ -90,13 +99,40 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --data #================================================= # CONFIGURE THE APP #================================================= -ynh_script_progression --message="Configuring the app..." --weight=15 +if [[ "$upgrade_type" == "UPGRADE_APP" || $(ynh_compare_current_package_version --comparison le --version "2.7.0~ynh4") ]]; then + ynh_script_progression --message="Configuring the app..." --weight=15 + + pushd $install_dir/build + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NEXT_TELEMETRY_DISABLED=1 yarn build + + # Actual app is a subset of release assets + # List of deps based on Dockerfile: https://github.com/umami-software/umami/blob/master/Dockerfile + ynh_secure_remove --file="node_modules/" + mv next.config.js .next/standalone/ + mv public .next/standalone/ + mv prisma .next/standalone/ + mv scripts .next/standalone/ + mv .next/static .next/standalone/.next + popd + + ynh_secure_remove --file="$install_dir/release" + + mkdir "$install_dir/release" + chmod -R o-rwx "$install_dir/release" + chown -R $app:www-data "$install_dir/release" + + mv -f $install_dir/build/.next/standalone/* $install_dir/build/.next/standalone/.[!.]* $install_dir/release + + pushd "$install_dir/release" + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn add npm-run-all dotenv prisma + popd +fi + +ynh_secure_remove --file="$install_dir/.cache" +ynh_secure_remove --file="$install_dir/build" -pushd $install_dir - ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NEXT_TELEMETRY_DISABLED=1 yarn build -popd #================================================= # START SYSTEMD SERVICE