cc-dashboard/deploy.sh
Vadym Samoilenko 968738a245 chore: add deploy.sh script
git pull → sync static to /var/www/html → docker compose build → restart app
Migrations run automatically on container start via alembic upgrade head.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 13:46:45 +00:00

35 lines
1.5 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
STATIC_SRC="/opt/cc-dashboard/src/static"
STATIC_DST="/var/www/html/cc-dashboard"
COMPOSE="docker compose -f /opt/cc-dashboard/docker-compose.yml"
log() { echo "[$(date '+%H:%M:%S')] $*"; }
die() { echo "[ERROR] $*" >&2; exit 1; }
cd /opt/cc-dashboard || die "Cannot cd to /opt/cc-dashboard"
# ── 1. Pull latest code ──────────────────────────────────────────────────────
log "Pulling latest code..."
git pull
# ── 2. Sync static files to web root ────────────────────────────────────────
log "Syncing static files to $STATIC_DST..."
sudo rsync -a --delete "$STATIC_SRC/" "$STATIC_DST/"
# ── 3. Rebuild app image ─────────────────────────────────────────────────────
log "Building app image..."
$COMPOSE build app
# ── 4. Restart app (migrations run automatically on container start) ─────────
log "Restarting app container..."
$COMPOSE up -d --no-deps app
# ── 5. Wait for healthy + show logs ─────────────────────────────────────────
log "Waiting for container to start..."
sleep 3
$COMPOSE ps app
$COMPOSE logs --tail=30 app
log "Deploy complete."