#!/bin/bash
set -e
cd /opt/projects

BACKUP="aegisone-py-backup-$(date +%Y%m%d-%H%M%S)"
echo "Backing up current to $BACKUP..."
mv aegisone-py "$BACKUP" 2>/dev/null || true

echo "Extracting new version..."
mkdir -p aegisone-py
cd aegisone-py
unzip -q ../aegisone-py-deploy.zip

echo "Building and restarting..."
docker compose build --no-cache --network host
docker compose up -d

echo "Deploy complete"
