From 28d34e9169f9afaee47f4c295e22e22185f5e37e Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Sun, 21 Dec 2025 23:15:08 +0100 Subject: [PATCH] Optimize Jotty installation with standalone mode (#10207) * Optimize Jotty installation with standalone mode - Use Next.js standalone mode to reduce folder size from ~2.4GB to ~80MB - Copy public, howto, and static folders to standalone output - Remove node_modules and build artifacts after creating standalone version - Update systemd service to use node directly instead of yarn start - Improves build efficiency and reduces disk usage Implements #10178 Co-authored-by: fccview * Apply standalone mode optimization to Jotty update script - Use standalone mode in update_script function - Ensures updates maintain the optimized deployment structure - Consistent with install script changes * Update systemd service in jotty update script - Recreate systemd service file with correct ExecStart command - Change from 'yarn start' to '/usr/bin/node server.js' - Ensures old installations get updated service configuration - Run daemon-reload after service file update --------- Co-authored-by: fccview --- ct/jotty.sh | 29 +++++++++++++++++++++++++++++ install/jotty-install.sh | 14 +++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/ct/jotty.sh b/ct/jotty.sh index 2b0836d5d..573140074 100644 --- a/ct/jotty.sh +++ b/ct/jotty.sh @@ -48,6 +48,17 @@ function update_script() { $STD yarn --frozen-lockfile $STD yarn next telemetry disable $STD yarn build + + [ -d "public" ] && cp -r public .next/standalone/ + [ -d "howto" ] && cp -r howto .next/standalone/ + mkdir -p .next/standalone/.next + cp -r .next/static .next/standalone/.next/ + + mv .next/standalone /tmp/jotty_standalone + rm -rf * .next .git .gitignore .yarn + mv /tmp/jotty_standalone/* . + mv /tmp/jotty_standalone/.[!.]* . 2>/dev/null || true + rm -rf /tmp/jotty_standalone msg_ok "Updated jotty" msg_info "Restoring configuration & data" @@ -55,6 +66,24 @@ function update_script() { $STD tar -xf /opt/data_config.tar msg_ok "Restored configuration & data" + msg_info "Updating Service" + cat </etc/systemd/system/jotty.service +[Unit] +Description=jotty server +After=network.target + +[Service] +WorkingDirectory=/opt/jotty +EnvironmentFile=/opt/jotty/.env +ExecStart=/usr/bin/node server.js +Restart=on-abnormal + +[Install] +WantedBy=multi-user.target +EOF + systemctl daemon-reload + msg_ok "Updated Service" + msg_info "Starting Service" systemctl start jotty msg_ok "Started Service" diff --git a/install/jotty-install.sh b/install/jotty-install.sh index 7eb82583f..d5cc534c3 100644 --- a/install/jotty-install.sh +++ b/install/jotty-install.sh @@ -21,6 +21,18 @@ cd /opt/jotty $STD yarn --frozen-lockfile $STD yarn next telemetry disable $STD yarn build + +[ -d "public" ] && cp -r public .next/standalone/ +[ -d "howto" ] && cp -r howto .next/standalone/ +mkdir -p .next/standalone/.next +cp -r .next/static .next/standalone/.next/ + +mv .next/standalone /tmp/jotty_standalone +rm -rf * .next .git .gitignore .yarn +mv /tmp/jotty_standalone/* . +mv /tmp/jotty_standalone/.[!.]* . 2>/dev/null || true +rm -rf /tmp/jotty_standalone + mkdir -p data/{users,checklists,notes} cat </opt/jotty/.env @@ -55,7 +67,7 @@ After=network.target [Service] WorkingDirectory=/opt/jotty EnvironmentFile=/opt/jotty/.env -ExecStart=yarn start +ExecStart=/usr/bin/node server.js Restart=on-abnormal [Install]