feat(devops): unify frontend docker build and root env injection
This commit is contained in:
+20
-28
@@ -2,41 +2,33 @@
|
||||
set -e
|
||||
|
||||
echo "======================================"
|
||||
echo " Upgrading NexusGuard SD-WAN Suite "
|
||||
echo " Upgrading NexusGuard SD-WAN Suite... "
|
||||
echo "======================================"
|
||||
|
||||
# Step 1: Docker down
|
||||
echo "[+] Stopping Docker containers..."
|
||||
docker-compose down --remove-orphans
|
||||
echo "[+] Docker containers stopped."
|
||||
# Pastikan file env ada
|
||||
if [ ! -f .env ]; then
|
||||
echo "[-] ERROR: .env file not found. Please run ./setup.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 2: Git pull main repo
|
||||
echo "[+] Pulling latest main repo..."
|
||||
git pull
|
||||
echo "[+] Pulling latest source code from repository..."
|
||||
git pull origin main || echo "[!] Git pull skipped or failed, continuing..."
|
||||
|
||||
# Step 3: Update submodules
|
||||
echo "[+] Updating submodules..."
|
||||
git submodule update --init --recursive
|
||||
echo "[+] Sourcing environment variables from root .env..."
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
|
||||
# Step 4: Submodule checkout — pull latest main on each
|
||||
for sub in apps/server-core apps/device-agent apps/dashboard-ui; do
|
||||
if [ -d "$sub" ]; then
|
||||
echo "[+] Updating $sub..."
|
||||
cd "$sub"
|
||||
git checkout main 2>/dev/null || git checkout master 2>/dev/null || true
|
||||
git pull
|
||||
cd - > /dev/null
|
||||
fi
|
||||
done
|
||||
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
|
||||
|
||||
# Step 5: Re-check superproject submodule pointers
|
||||
git submodule update --remote --merge 2>/dev/null || true
|
||||
|
||||
# Step 6: Docker up
|
||||
echo "[+] Starting Docker containers..."
|
||||
echo "[+] Restarting containers..."
|
||||
docker-compose up -d
|
||||
|
||||
echo "[+] Cleaning up unused dangling images to free up space..."
|
||||
docker image prune -f
|
||||
|
||||
echo "======================================"
|
||||
echo " NexusGuard upgrade complete! "
|
||||
echo " API Port : 8080 "
|
||||
echo " Upgrade & Rebuild complete! "
|
||||
echo " Dashboard : http://localhost"
|
||||
echo " API Port : ${API_PORT:-8080}"
|
||||
echo "======================================"
|
||||
|
||||
Reference in New Issue
Block a user