social-reporting-tool/deploy/deploy.sh
Vadym Samoilenko 7a70283e5b Fix frontend not being copied to /var/www/html on deploy
- Replace cp frontend/* with cp -r frontend/. to copy all files reliably
- Add mkdir -p as safety net in deploy.sh
- Add apache2 reload after frontend copy in deploy.sh
- setup.sh now copies entire frontend dir instead of hardcoded filenames

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 18:37:27 +01:00

52 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
# ═══════════════════════════════════════════════════════
# Social Reporting — Quick Deploy (updates only)
# Run from anywhere: bash /opt/social-reporting/deploy/deploy.sh
# ═══════════════════════════════════════════════════════
BACKEND_DIR="/opt/social-reporting"
FRONTEND_DIR="/var/www/html/social-reporting"
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
log() { echo -e "${GREEN}[+]${NC} $1"; }
err() { echo -e "${RED}[x]${NC} $1"; exit 1; }
cd "$BACKEND_DIR" || err "Backend dir not found: $BACKEND_DIR"
# 1. Pull latest code
log "Pulling latest code..."
git pull origin main
# 2. Copy frontend
log "Deploying frontend..."
sudo mkdir -p "$FRONTEND_DIR"
sudo cp -r frontend/. "$FRONTEND_DIR/"
sudo chown -R www-data:www-data "$FRONTEND_DIR"
sudo systemctl reload apache2
# 3. Fix volume permissions for node user (uid 1000)
log "Fixing volume permissions..."
sudo chown -R 1000:1000 "$BACKEND_DIR/agents/social-listening/outputs" "$BACKEND_DIR/agents/social-listening/briefs"
# 4. Rebuild and restart containers
log "Rebuilding containers..."
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
# 5. Wait for health check
log "Waiting for backend..."
for i in {1..10}; do
if curl -sf http://127.0.0.1:3456/status > /dev/null 2>&1; then
log "Backend is healthy"
break
fi
[ "$i" -eq 10 ] && err "Backend not responding — check: docker compose logs social-listening"
sleep 2
done
echo ""
echo -e "${GREEN}Deploy complete!${NC}"