Some checks are pending
Playwright Tests / test (push) Waiting to run
next.config.js sets output: 'standalone', but Next.js does not copy public/ or .next/static/ into .next/standalone — that is a documented manual step. Skipping it shipped new server code referencing new chunk hashes while the old chunks stayed in the standalone tree, so those requests 404'd, React never hydrated, and pages hung on "Loading session..." while the API kept returning 200. v1.114.2 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
57 lines
2.2 KiB
Bash
57 lines
2.2 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Deploy script for the production host (WebApp-Testing-live).
|
|
#
|
|
# The app runs there as a PM2 process ("my-weekly-todo") from /root/My-Weekly-ToDo-List.
|
|
# It is NOT run under Docker — deploy.sh and docker-compose.yml in this repo describe an
|
|
# older Portainer setup that is not what serves todo.martin-bierschenk.de.
|
|
#
|
|
# Usage on the host: /root/My-Weekly-ToDo-List/scripts/update-app.sh
|
|
#
|
|
# The whole body is wrapped in a function so bash parses it in one go: this script lives
|
|
# inside the very checkout it updates, and `git pull` rewriting it mid-run would otherwise
|
|
# make bash resume at a stale file offset.
|
|
|
|
main() {
|
|
set -euo pipefail
|
|
|
|
# Fail fast instead of hanging on a credential prompt when run without a terminal
|
|
# (e.g. from systemd). The host authenticates via a read-only SSH deploy key.
|
|
export GIT_TERMINAL_PROMPT=0
|
|
|
|
local APP_DIR="/root/My-Weekly-ToDo-List"
|
|
local PM2_APP="my-weekly-todo"
|
|
|
|
cd "$APP_DIR"
|
|
|
|
echo "--- Pulling latest changes from git ---"
|
|
git pull origin main
|
|
|
|
# npm ci, not npm install: it installs exactly what package-lock.json specifies and
|
|
# never rewrites it. npm install rewrites the lockfile, which leaves the working tree
|
|
# dirty and makes the *next* git pull abort.
|
|
echo "--- Installing dependencies ---"
|
|
npm ci
|
|
|
|
echo "--- Building application ---"
|
|
npm run build
|
|
|
|
# next.config.js sets output: 'standalone', and Next.js does NOT copy public/ or
|
|
# .next/static/ into .next/standalone — that is a documented manual step. Skipping it
|
|
# ships new server code whose HTML references new chunk hashes while the old chunks sit
|
|
# in the standalone tree: they 404, React never hydrates, and every page hangs on its
|
|
# server-rendered shell ("Loading session...") while the API still answers 200.
|
|
echo "--- Copying static assets into standalone output ---"
|
|
cp -r public .next/standalone/
|
|
cp -r .next/static .next/standalone/.next/
|
|
|
|
echo "--- Restarting PM2 process ---"
|
|
pm2 restart "$PM2_APP" --update-env
|
|
pm2 save
|
|
|
|
echo "--- Update Complete ---"
|
|
echo "Deployed version: $(node -p "require('$APP_DIR/package.json').version")"
|
|
}
|
|
|
|
main "$@"
|