chore: refactor and merge DevOps scripts (setup.sh and update.sh)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/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..."
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
|
||||
# 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. 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 "========================================="
|
||||
Reference in New Issue
Block a user