51 lines
1.8 KiB
Bash
Executable File
51 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Fast deploy for LeoCRM.
|
|
# Usage:
|
|
# bash scripts/fast-deploy.sh frontend # Frontend-only: build + copy (~20s)
|
|
# bash scripts/fast-deploy.sh full # Full: Coolify rebuild (~2min)
|
|
# Default: frontend
|
|
|
|
set -euo pipefail
|
|
|
|
SERVER="root@46.225.91.159"
|
|
SSH_KEY="${SSH_KEY:-/a0/usr/workdir/.ssh/coolify-01-root}"
|
|
SSH_OPTS="-o StrictHostKeyChecking=no -i $SSH_KEY"
|
|
MODE="${1:-frontend}"
|
|
|
|
cd /a0/usr/workdir/leocrm-fix
|
|
|
|
if [ "$MODE" = "full" ]; then
|
|
echo "[Full Deploy] Triggering Coolify rebuild..."
|
|
COOLIFY_API_TOKEN='2|UnMMp2WYbXFJCrOuZ1yqSK96hMooPTAfAJPIXiQc1e47154e' \
|
|
COOLIFY_APP_UUID='stvabl4vaqru7jclx4ittzr3' \
|
|
COOLIFY_BASE_URL='https://server.media-on.de' \
|
|
SSH_KEY="$SSH_KEY" \
|
|
SERVER_IP='46.225.91.159' \
|
|
/opt/venv/bin/python scripts/deploy.py
|
|
exit 0
|
|
fi
|
|
|
|
# Frontend-only fast deploy
|
|
echo "[1/5] Building frontend..."
|
|
cd frontend
|
|
npm run build 2>&1 | tail -3
|
|
|
|
echo "[2/5] Finding container..."
|
|
CONTAINER=$(ssh $SSH_OPTS $SERVER 'docker ps --format "{{.Names}}" | grep "^stvabl4vaqru7jclx4ittzr3-" | head -1')
|
|
if [ -z "$CONTAINER" ]; then
|
|
echo "ERROR: Could not find app container"
|
|
exit 1
|
|
fi
|
|
echo " Container: $CONTAINER"
|
|
|
|
echo "[3/5] Packaging & uploading..."
|
|
tar czf /tmp/frontend-dist.tar.gz -C dist .
|
|
scp $SSH_OPTS /tmp/frontend-dist.tar.gz $SERVER:/tmp/frontend-dist.tar.gz
|
|
|
|
echo "[4/5] Copying into container..."
|
|
ssh $SSH_OPTS $SERVER "docker cp /tmp/frontend-dist.tar.gz $CONTAINER:/tmp/ && docker exec $CONTAINER sh -c 'cd /app/frontend/dist && tar xzf /tmp/frontend-dist.tar.gz --overwrite && rm -f /tmp/frontend-dist.tar.gz 2>/dev/null || true' && rm -f /tmp/frontend-dist.tar.gz 2>/dev/null || true"
|
|
|
|
echo "[5/5] Done! Frontend deployed in ~20s."
|
|
echo " No restart needed — static files served directly."
|
|
echo " Browser: Strg+Shift+R for hard reload."
|