From 2943f48035566d0009ea2cba0547651236a86a0c Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 29 Aug 2026 02:02:42 -0500 Subject: [PATCH] Run Next.js via standalone server.js under systemd. Co-authored-by: Cursor --- deploy/systemd/nomadro-web.service | 4 ++-- scripts/deploy_update.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/deploy/systemd/nomadro-web.service b/deploy/systemd/nomadro-web.service index 6580455..33aad52 100644 --- a/deploy/systemd/nomadro-web.service +++ b/deploy/systemd/nomadro-web.service @@ -5,14 +5,14 @@ Wants=nomadro-api.service [Service] Type=simple -WorkingDirectory=/opt/nomadweb/frontend +WorkingDirectory=/opt/nomadweb/frontend/.next/standalone Environment=NODE_ENV=production Environment=PORT=3055 Environment=HOSTNAME=127.0.0.1 Environment=NEXT_TELEMETRY_DISABLED=1 Environment=NEXT_PUBLIC_API_URL=https://nomadweb.nomadro.com/api/v1 Environment=NEXT_PUBLIC_SITE_URL=https://nomadweb.nomadro.com -ExecStart=/usr/bin/npm run start -- -H 127.0.0.1 -p 3055 +ExecStart=/usr/bin/node server.js Restart=always RestartSec=3 User=root diff --git a/scripts/deploy_update.py b/scripts/deploy_update.py index a31a1d1..8427220 100644 --- a/scripts/deploy_update.py +++ b/scripts/deploy_update.py @@ -111,9 +111,14 @@ export NODE_ENV=production build_frontend() { cd "$REMOTE/frontend" if [ ! -d node_modules ] || echo "${CHANGED:-}" | grep -qE '^frontend/package(-lock)?\.json$'; then - npm ci --legacy-peer-deps --prefer-offline + npm ci --legacy-peer-deps --include=dev --prefer-offline fi npm run build + # Prepare standalone runtime layout for systemd + mkdir -p .next/standalone/.next + rm -rf .next/standalone/public .next/standalone/.next/static + cp -a public .next/standalone/public + cp -a .next/static .next/standalone/.next/static systemctl restart nomadro-web }