#!/bin/bash
# ── CLC Store — Deploy / Update Script ──────────────────────────────────────
# Run this on the server via SSH whenever you push new code.
# Usage: bash deploy.sh

set -e

echo "🐟 CLC Fishery Store — Deploying..."

# Install / update dependencies
echo "📦 Installing dependencies..."
npm install --production=false

# Build Next.js
echo "🔨 Building..."
npm run build

# Restart with PM2 (starts fresh if not running, gracefully restarts if running)
echo "🚀 Restarting with PM2..."
pm2 startOrReload ecosystem.config.js --env production

echo "✅ Done! App running on port 3001"
pm2 status clc-store
