Run Next.js via standalone server.js under systemd.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
e8d225390d
commit
2943f48035
@ -5,14 +5,14 @@ Wants=nomadro-api.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/opt/nomadweb/frontend
|
WorkingDirectory=/opt/nomadweb/frontend/.next/standalone
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
Environment=PORT=3055
|
Environment=PORT=3055
|
||||||
Environment=HOSTNAME=127.0.0.1
|
Environment=HOSTNAME=127.0.0.1
|
||||||
Environment=NEXT_TELEMETRY_DISABLED=1
|
Environment=NEXT_TELEMETRY_DISABLED=1
|
||||||
Environment=NEXT_PUBLIC_API_URL=https://nomadweb.nomadro.com/api/v1
|
Environment=NEXT_PUBLIC_API_URL=https://nomadweb.nomadro.com/api/v1
|
||||||
Environment=NEXT_PUBLIC_SITE_URL=https://nomadweb.nomadro.com
|
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
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
User=root
|
User=root
|
||||||
|
|||||||
@ -111,9 +111,14 @@ export NODE_ENV=production
|
|||||||
build_frontend() {
|
build_frontend() {
|
||||||
cd "$REMOTE/frontend"
|
cd "$REMOTE/frontend"
|
||||||
if [ ! -d node_modules ] || echo "${CHANGED:-}" | grep -qE '^frontend/package(-lock)?\.json$'; then
|
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
|
fi
|
||||||
npm run build
|
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
|
systemctl restart nomadro-web
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user