Files
Nexus-Guard-Suite/update.sh
T

46 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -e
echo "========================================="
echo " NexusGuard SD-WAN: SYSTEM UPDATE "
echo "========================================="
# 1. Pastikan file env ada
if [ ! -f .env ]; then
echo "[-] ERROR: .env file not found. Please run ./setup.sh first to initialize configuration."
exit 1
fi
# 2. Update Code dari Git (Main & Submodules)
echo "[+] Pulling latest source code from repository..."
git pull origin main || echo "[!] Git pull for main repo skipped or failed, continuing..."
echo "[+] Syncing and updating submodules..."
git submodule update --init --recursive --remote || echo "[!] Git submodule update skipped or failed."
# 3. Source variabel dari .env untuk dimasukkan ke build process (contoh: VITE_API_BASE_URL)
echo "[+] Sourcing environment variables from root .env..."
set -a && . .env && set +a
# 4. Rebuild Images & Restart Containers
echo "[+] Rebuilding Docker images (injecting new environment variables)..."
# Menggunakan --build-arg untuk memastikan Vue/Vite membaca domain API baru
docker compose build --build-arg VITE_API_BASE_URL=$VITE_API_BASE_URL
echo "[+] Restarting containers..."
docker compose up -d
# 5. Run Database Migrations
echo "[+] Running automated database migrations..."
docker exec nexus-guard-suite-server-core-1 ./server-core -migrate-prod || echo "[!] Migration skipped or failed. It might not be needed."
# 6. Cleanup
echo "[+] Cleaning up unused dangling images to free up space..."
docker image prune -f
echo "========================================="
echo " Update & Deployment complete! "
echo " Dashboard : http://localhost:${WEB_PORT:-80}"
echo " API Port : ${API_PORT:-8080}"
echo "========================================="