1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/umami_ynh.git synced 2024-10-01 13:34:50 +02:00

Trim down assets.

This commit is contained in:
orhtej2 2023-09-11 12:11:01 +02:00
parent 44da507105
commit 2a570a26fe
4 changed files with 35 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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,35 @@ 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/
popd
mkdir "$install_dir/release"
chmod -R o-rwx "$install_dir/release"
chown -R $app:www-data "$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
mv -f $install_dir/build/.next/standalone/* $install_dir/release
rm -rf $install_dir/.cache
rm -rf $install_dir/build
#=================================================
# START SYSTEMD SERVICE
#=================================================

View file

@ -45,12 +45,14 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=5
ynh_secure_remove --file="$install_dir/release"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 #--keep=".env"
ynh_setup_source --dest_dir="$install_dir/build" --full_replace=1 #--keep=".env"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R o-rwx "$install_dir/build"
chown -R $app:www-data "$install_dir/build"
#=================================================
# UPGRADE DEPENDENCIES