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
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:
36
deploy.sh
36
deploy.sh
@ -8,7 +8,7 @@
|
||||
# - Rebuilds frontend in background
|
||||
# ============================================================================
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
@ -25,6 +25,12 @@ SERVER_PATH="/home/user/pounce"
|
||||
SERVER_PASS="user"
|
||||
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
|
||||
QUICK_MODE=false
|
||||
BACKEND_ONLY=false
|
||||
@ -109,7 +115,7 @@ fi
|
||||
# Step 3: Reload backend (graceful, no restart)
|
||||
if ! $FRONTEND_ONLY; then
|
||||
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
|
||||
|
||||
cd ~/pounce/backend
|
||||
@ -150,9 +156,17 @@ fi
|
||||
# Step 4: Rebuild frontend (in background to minimize downtime)
|
||||
if ! $BACKEND_ONLY; then
|
||||
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
|
||||
|
||||
echo " Installing dependencies..."
|
||||
if [ -f "package-lock.json" ]; then
|
||||
npm ci
|
||||
else
|
||||
npm install
|
||||
fi
|
||||
|
||||
# Build new version
|
||||
echo " Building..."
|
||||
npm run build
|
||||
@ -165,7 +179,7 @@ if ! $BACKEND_ONLY; then
|
||||
ln -sfn ../../public .next/standalone/public
|
||||
|
||||
# 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
|
||||
echo " Restarting Next.js (PID: $NEXT_PID)..."
|
||||
@ -178,18 +192,28 @@ if ! $BACKEND_ONLY; then
|
||||
sleep 1
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
echo " ✓ Frontend running (PID: $NEW_PID)"
|
||||
else
|
||||
echo " ⚠ Frontend may not have started correctly"
|
||||
echo " Last 80 lines of frontend.log:"
|
||||
tail -n 80 frontend.log || true
|
||||
fi
|
||||
else
|
||||
echo " ✗ Build failed, keeping old version"
|
||||
echo " Last 120 lines of build output (frontend.log):"
|
||||
tail -n 120 frontend.log || true
|
||||
fi
|
||||
FRONTEND_EOF
|
||||
else
|
||||
|
||||
@ -168,7 +168,7 @@ export default function CfoPage() {
|
||||
</main>
|
||||
|
||||
{toast && (
|
||||
<Toast message={toast.message} type={toast.type} isVisible={toast.isVisible} onClose={hideToast} />
|
||||
<Toast message={toast.message} type={toast.type} onClose={hideToast} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -49,7 +49,6 @@ export default function HuntPage() {
|
||||
<Toast
|
||||
message={toast.message}
|
||||
type={toast.type}
|
||||
isVisible={toast.isVisible}
|
||||
onClose={hideToast}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user