Add deployment script for git-based deployments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
michael 2025-12-09 11:13:37 -06:00
parent 6b7f8763c0
commit a32512a8f4

63
deploy.sh Executable file
View file

@ -0,0 +1,63 @@
#!/bin/bash
set -e # Exit on any error
# Configuration
DEPLOY_DIR="/opt/semblance"
FRONTEND_DEST="/var/www/html/semblance"
PYTHON_CMD="python3.13"
echo "======================================"
echo "Starting deployment..."
echo "======================================"
# Step 1: Pull latest changes
echo ""
echo "[1/6] Pulling latest changes from git..."
cd "$DEPLOY_DIR"
git pull
# Step 2: Set up frontend environment
echo ""
echo "[2/6] Setting up frontend environment..."
cp .env.production .env
# Step 3: Set up Python virtual environment
echo ""
echo "[3/6] Setting up Python virtual environment..."
cd "$DEPLOY_DIR/backend"
if [ ! -d "venv" ]; then
echo "Creating new virtual environment with $PYTHON_CMD..."
$PYTHON_CMD -m venv venv
else
echo "Virtual environment already exists."
fi
# Step 4: Install Python dependencies
echo ""
echo "[4/6] Installing Python dependencies..."
source venv/bin/activate
pip install -r requirements.txt --quiet
# Step 5: Build and deploy frontend
echo ""
echo "[5/6] Building and deploying frontend..."
cd "$DEPLOY_DIR"
npm install --silent
npm run build
echo "Cleaning deployment directory..."
rm -rf "$FRONTEND_DEST"/*
echo "Copying new build..."
cp -r dist/* "$FRONTEND_DEST/"
# Step 6: Restart backend service
echo ""
echo "[6/6] Restarting backend service..."
sudo systemctl restart semblance.service
echo ""
echo "======================================"
echo "Deployment complete!"
echo "======================================"
echo ""
systemctl status semblance.service --no-pager