82 lines
2.3 KiB
Bash
Executable file
82 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# NotebookLlama Frontend Deployment Script
|
|
# This script builds the Next.js standalone app with static assets on the server
|
|
|
|
set -e # Exit on any error
|
|
|
|
echo "==================================="
|
|
echo "NotebookLlama Frontend Deployment"
|
|
echo "==================================="
|
|
echo ""
|
|
|
|
# Navigate to the frontend directory
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
echo "Working directory: $(pwd)"
|
|
echo ""
|
|
|
|
# Step 1: Pull latest code
|
|
echo "Step 1: Pulling latest code from git..."
|
|
git pull origin main
|
|
echo "✓ Code updated"
|
|
echo ""
|
|
|
|
# Step 2: Install dependencies
|
|
echo "Step 2: Checking dependencies..."
|
|
if [ -f "package.json" ]; then
|
|
npm install
|
|
echo "✓ Dependencies installed"
|
|
else
|
|
echo "✗ package.json not found!"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Step 3: Build the application
|
|
echo "Step 3: Building Next.js application..."
|
|
echo "This will create the standalone build and copy static assets..."
|
|
npm run build
|
|
|
|
# Verify static assets were copied
|
|
if [ -d ".next/standalone/.next/static" ]; then
|
|
echo "✓ Static assets copied successfully"
|
|
else
|
|
echo "✗ Warning: Static assets not found in .next/standalone/.next/static"
|
|
echo " Attempting manual copy..."
|
|
mkdir -p .next/standalone/.next/
|
|
cp -r .next/static .next/standalone/.next/static
|
|
echo "✓ Manual copy completed"
|
|
fi
|
|
|
|
if [ -d ".next/standalone/public" ]; then
|
|
echo "✓ Public files copied successfully"
|
|
else
|
|
echo "✗ Warning: Public files not found in .next/standalone/public"
|
|
echo " Attempting manual copy..."
|
|
cp -r public .next/standalone/public
|
|
echo "✓ Manual copy completed"
|
|
fi
|
|
echo ""
|
|
|
|
# Step 4: Restart the service
|
|
echo "Step 4: Restarting systemd service..."
|
|
sudo systemctl restart notebookllama-frontend.service
|
|
echo "✓ Service restarted"
|
|
echo ""
|
|
|
|
# Step 5: Check service status
|
|
echo "Step 5: Checking service status..."
|
|
sleep 2 # Give the service a moment to start
|
|
sudo systemctl status notebookllama-frontend.service --no-pager -l
|
|
echo ""
|
|
|
|
echo "==================================="
|
|
echo "Deployment Complete!"
|
|
echo "==================================="
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Check the service logs: sudo journalctl -u notebookllama-frontend.service -f"
|
|
echo "2. Test the application in your browser"
|
|
echo ""
|