tractatus/scripts/deploy-security-middleware.sh
TheFlow b6c7e96823 docs: fix rsync deployment issue and create deployment script
Problem: rsync with trailing slashes copied directory contents to wrong location
Solution: Created automated deployment script with correct patterns

Changes:
- Created scripts/deploy-security-middleware.sh (automated deployment)
- Created docs/DEPLOYMENT_RSYNC_PATTERNS.md (rsync best practices)
- Cleaned up incorrectly placed files on production
- Documented trailing slash behavior and correct patterns

This prevents future deployment issues and provides reliable automation.
2025-10-14 15:45:39 +13:00

69 lines
2 KiB
Bash
Executable file

#!/bin/bash
###############################################################################
# Tractatus Security Middleware Deployment Script
# Deploys security middleware and routes to production with correct structure
###############################################################################
set -e # Exit on error
# Configuration
REMOTE_USER="ubuntu"
REMOTE_HOST="vps-93a693da.vps.ovh.net"
SSH_KEY="$HOME/.ssh/tractatus_deploy"
REMOTE_PATH="/var/www/tractatus"
LOCAL_PATH="/home/theflow/projects/tractatus"
echo "========================================="
echo "Tractatus Security Deployment"
echo "========================================="
echo ""
# Verify we're in the correct directory
if [ ! -f "package.json" ] || [ ! -d "src/middleware" ]; then
echo "❌ Error: Must run from tractatus project root"
exit 1
fi
echo "📋 Deploying files to production..."
echo ""
# Deploy security middleware
echo "1. Deploying security middleware..."
rsync -avz --chmod=D755,F644 -e "ssh -i $SSH_KEY" \
src/middleware/ \
${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}/src/middleware/
# Deploy routes
echo "2. Deploying routes..."
rsync -avz --chmod=D755,F644 -e "ssh -i $SSH_KEY" \
src/routes/ \
${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}/src/routes/
# Deploy server.js and utils
echo "3. Deploying server.js and utilities..."
rsync -avz --chmod=D755,F644 -e "ssh -i $SSH_KEY" \
src/server.js \
src/utils/security-logger.js \
${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}/src/
# Verify deployment
echo ""
echo "✅ Files deployed successfully"
echo ""
# Restart service
echo "🔄 Restarting Tractatus service..."
ssh -i $SSH_KEY ${REMOTE_USER}@${REMOTE_HOST} "sudo systemctl restart tractatus"
sleep 3
# Check status
echo ""
echo "📊 Service status:"
ssh -i $SSH_KEY ${REMOTE_USER}@${REMOTE_HOST} "sudo systemctl status tractatus --no-pager -l | head -15"
echo ""
echo "========================================="
echo "✨ Deployment complete!"
echo "========================================="