mirror of
https://github.com/YunoHost-Apps/umami_ynh.git
synced 2024-10-01 13:34:50 +02:00
Only keep necessary assets. (#33)
* Trim down assets. * Yarn restore after copying data * Also copy hidden folders * Properly move static * Change the update script * Use proper build path. * Fix version checking? * Another version check fix? * Fix removal of old files. * Fix pattern for removal. * Use ynh_secure_remove * Don't use rm * Properly move files * Fix app upgrade.
This commit is contained in:
parent
8629e3c9c5
commit
d76186fb7d
4 changed files with 81 additions and 22 deletions
|
@ -3,3 +3,4 @@ DATABASE_URL=postgresql://__DB_USER__:__DB_PWD__@127.0.0.1:5432/__DB_NAME__
|
||||||
DISABLE_TELEMETRY=1
|
DISABLE_TELEMETRY=1
|
||||||
PORT=__PORT__
|
PORT=__PORT__
|
||||||
DEFAULT_LOCALE="__LANGUAGE__"
|
DEFAULT_LOCALE="__LANGUAGE__"
|
||||||
|
NODE_ENV=production
|
||||||
|
|
|
@ -6,7 +6,7 @@ After=network.target
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__INSTALL_DIR__/
|
WorkingDirectory=__INSTALL_DIR__/release
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
Environment="__YNH_NODE_LOAD_PATH__"
|
Environment="__YNH_NODE_LOAD_PATH__"
|
||||||
Environment=NEXT_TELEMETRY_DISABLED=1
|
Environment=NEXT_TELEMETRY_DISABLED=1
|
||||||
|
|
|
@ -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
|
ynh_script_progression --message="Setting up source files..." --weight=5
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# 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"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$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_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"
|
chmod 650 "$install_dir/build/.env"
|
||||||
chown $app:$app "$install_dir/.env"
|
chown $app:$app "$install_dir/build/.env"
|
||||||
|
|
||||||
ynh_script_progression --message="Provisioning pgcrypto..." --weight=1
|
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
|
ynh_script_progression --message="Configuring the app..." --weight=15
|
||||||
|
|
||||||
pushd $install_dir
|
pushd "$install_dir/build"
|
||||||
ynh_use_nodejs
|
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 yarn install
|
||||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NEXT_TELEMETRY_DISABLED=1 yarn build
|
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
|
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
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -41,16 +41,25 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if $(ynh_compare_current_package_version --comparison le --version "2.7.0~ynh4")
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=5
|
# Purge old root directory's contents
|
||||||
|
ynh_script_progression --message="Removing old files..." --weight=2
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
mkdir /tmp/release
|
||||||
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 #--keep=".env"
|
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
|
fi
|
||||||
|
|
||||||
chmod -R o-rwx "$install_dir"
|
if [[ "$upgrade_type" == "UPGRADE_APP" || $(ynh_compare_current_package_version --comparison le --version "2.7.0~ynh4") ]]; then
|
||||||
chown -R $app:www-data "$install_dir"
|
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
|
# 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_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"
|
chmod 650 "$install_dir/build/.env"
|
||||||
chown $app:$app "$install_dir/.env"
|
chown $app:$app "$install_dir/build/.env"
|
||||||
|
|
||||||
ynh_script_progression --message="Provisioning pgcrypto..." --weight=1
|
ynh_script_progression --message="Provisioning pgcrypto..." --weight=1
|
||||||
|
|
||||||
|
@ -90,14 +99,41 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --data
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE THE APP
|
# CONFIGURE THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
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
|
ynh_script_progression --message="Configuring the app..." --weight=15
|
||||||
|
|
||||||
pushd $install_dir
|
pushd $install_dir/build
|
||||||
ynh_use_nodejs
|
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 yarn install
|
||||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NEXT_TELEMETRY_DISABLED=1 yarn build
|
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
|
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"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue