fix: unblock production frontend build
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled

Remove unsupported Toast isVisible prop and harden deploy script to reliably rebuild/restart Next.js standalone on the server.
This commit is contained in:
2025-12-15 16:41:24 +01:00
parent 61cd40be6a
commit 342bebc483
3 changed files with 31 additions and 8 deletions

View File

@ -8,7 +8,7 @@
# - Rebuilds frontend in background # - Rebuilds frontend in background
# ============================================================================ # ============================================================================
set -e set -euo pipefail
# Colors # Colors
GREEN='\033[0;32m' GREEN='\033[0;32m'
@ -25,6 +25,12 @@ SERVER_PATH="/home/user/pounce"
SERVER_PASS="user" SERVER_PASS="user"
SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
if ! command -v sshpass >/dev/null 2>&1; then
echo -e "${RED}✗ sshpass is required but not installed.${NC}"
echo -e " Install with: ${CYAN}brew install sshpass${NC}"
exit 1
fi
# Parse flags # Parse flags
QUICK_MODE=false QUICK_MODE=false
BACKEND_ONLY=false BACKEND_ONLY=false
@ -109,7 +115,7 @@ fi
# Step 3: Reload backend (graceful, no restart) # Step 3: Reload backend (graceful, no restart)
if ! $FRONTEND_ONLY; then if ! $FRONTEND_ONLY; then
echo -e "\n${YELLOW}[3/4] Reloading backend (graceful)...${NC}" echo -e "\n${YELLOW}[3/4] Reloading backend (graceful)...${NC}"
sshpass -p "$SERVER_PASS" ssh -tt $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'BACKEND_EOF' sshpass -p "$SERVER_PASS" ssh $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'BACKEND_EOF'
set -e set -e
cd ~/pounce/backend cd ~/pounce/backend
@ -150,9 +156,17 @@ fi
# Step 4: Rebuild frontend (in background to minimize downtime) # Step 4: Rebuild frontend (in background to minimize downtime)
if ! $BACKEND_ONLY; then if ! $BACKEND_ONLY; then
echo -e "\n${YELLOW}[4/4] Rebuilding frontend...${NC}" echo -e "\n${YELLOW}[4/4] Rebuilding frontend...${NC}"
sshpass -p "$SERVER_PASS" ssh -tt $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'FRONTEND_EOF' sshpass -p "$SERVER_PASS" ssh $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'FRONTEND_EOF'
set -e
cd ~/pounce/frontend cd ~/pounce/frontend
echo " Installing dependencies..."
if [ -f "package-lock.json" ]; then
npm ci
else
npm install
fi
# Build new version # Build new version
echo " Building..." echo " Building..."
npm run build npm run build
@ -165,7 +179,7 @@ if ! $BACKEND_ONLY; then
ln -sfn ../../public .next/standalone/public ln -sfn ../../public .next/standalone/public
# Gracefully restart Next.js # Gracefully restart Next.js
NEXT_PID=$(pgrep -af 'next-serv|next start|node \\.next/standalone/server\\.js' | awk 'NR==1{print $1; exit}') NEXT_PID=$(pgrep -af 'node \\.next/standalone/server\\.js|next start|next-server|next-serv' | awk 'NR==1{print $1; exit}')
if [ -n "$NEXT_PID" ]; then if [ -n "$NEXT_PID" ]; then
echo " Restarting Next.js (PID: $NEXT_PID)..." echo " Restarting Next.js (PID: $NEXT_PID)..."
@ -178,18 +192,28 @@ if ! $BACKEND_ONLY; then
sleep 1 sleep 1
# Start new instance # Start new instance
nohup npm run start > frontend.log 2>&1 & if [ -f ".next/standalone/server.js" ]; then
echo " Starting Next.js (standalone)..."
nohup env NODE_ENV=production HOSTNAME=0.0.0.0 PORT=3000 node .next/standalone/server.js > frontend.log 2>&1 &
else
echo " Starting Next.js (npm start)..."
nohup env NODE_ENV=production npm run start > frontend.log 2>&1 &
fi
sleep 2 sleep 2
# Verify # Verify
NEW_PID=$(pgrep -af 'next-serv|next start|node \\.next/standalone/server\\.js' | awk 'NR==1{print $1; exit}') NEW_PID=$(pgrep -af 'node \\.next/standalone/server\\.js|next start|next-server|next-serv' | awk 'NR==1{print $1; exit}')
if [ -n "$NEW_PID" ]; then if [ -n "$NEW_PID" ]; then
echo " ✓ Frontend running (PID: $NEW_PID)" echo " ✓ Frontend running (PID: $NEW_PID)"
else else
echo " ⚠ Frontend may not have started correctly" echo " ⚠ Frontend may not have started correctly"
echo " Last 80 lines of frontend.log:"
tail -n 80 frontend.log || true
fi fi
else else
echo " ✗ Build failed, keeping old version" echo " ✗ Build failed, keeping old version"
echo " Last 120 lines of build output (frontend.log):"
tail -n 120 frontend.log || true
fi fi
FRONTEND_EOF FRONTEND_EOF
else else

View File

@ -168,7 +168,7 @@ export default function CfoPage() {
</main> </main>
{toast && ( {toast && (
<Toast message={toast.message} type={toast.type} isVisible={toast.isVisible} onClose={hideToast} /> <Toast message={toast.message} type={toast.type} onClose={hideToast} />
)} )}
</div> </div>
) )

View File

@ -49,7 +49,6 @@ export default function HuntPage() {
<Toast <Toast
message={toast.message} message={toast.message}
type={toast.type} type={toast.type}
isVisible={toast.isVisible}
onClose={hideToast} onClose={hideToast}
/> />
)} )}