feat(devops): unify frontend docker build and root env injection

This commit is contained in:
datadunia
2026-05-16 02:32:52 +07:00
parent b4d15d72bd
commit 503f4b8c63
3 changed files with 37 additions and 31 deletions
+16 -2
View File
@@ -48,13 +48,12 @@ services:
- IPAM_POOL=10.8.0.0/16 - IPAM_POOL=10.8.0.0/16
- GIN_MODE=release - GIN_MODE=release
ports: ports:
- "8080:8080" - "${API_PORT:-8080}:8080"
depends_on: depends_on:
postgres: postgres:
condition: service_healthy condition: service_healthy
redis: redis:
condition: service_healthy condition: service_healthy
# Requires NET_ADMIN capability for nftables manipulation
cap_add: cap_add:
- NET_ADMIN - NET_ADMIN
- NET_RAW - NET_RAW
@@ -62,6 +61,21 @@ services:
networks: networks:
- nexusnet - nexusnet
dashboard-ui:
build:
context: ./apps/dashboard-ui
dockerfile: Dockerfile
args:
# Inject the root .env variable into the frontend build process
VITE_API_BASE_URL: ${VITE_API_BASE_URL}
ports:
- "80:80"
depends_on:
- server-core
restart: unless-stopped
networks:
- nexusnet
volumes: volumes:
pgdata: pgdata:
redisdata: redisdata:
+20 -28
View File
@@ -2,41 +2,33 @@
set -e set -e
echo "======================================" echo "======================================"
echo " Upgrading NexusGuard SD-WAN Suite " echo " Upgrading NexusGuard SD-WAN Suite... "
echo "======================================" echo "======================================"
# Step 1: Docker down # Pastikan file env ada
echo "[+] Stopping Docker containers..." if [ ! -f .env ]; then
docker-compose down --remove-orphans echo "[-] ERROR: .env file not found. Please run ./setup.sh first."
echo "[+] Docker containers stopped." exit 1
fi
# Step 2: Git pull main repo echo "[+] Pulling latest source code from repository..."
echo "[+] Pulling latest main repo..." git pull origin main || echo "[!] Git pull skipped or failed, continuing..."
git pull
# Step 3: Update submodules echo "[+] Sourcing environment variables from root .env..."
echo "[+] Updating submodules..." export $(grep -v '^#' .env | xargs)
git submodule update --init --recursive
# Step 4: Submodule checkout — pull latest main on each echo "[+] Rebuilding Docker images (injecting new environment variables)..."
for sub in apps/server-core apps/device-agent apps/dashboard-ui; do # Menggunakan --build-arg untuk memastikan Vue/Vite membaca domain API baru
if [ -d "$sub" ]; then docker-compose build --build-arg VITE_API_BASE_URL=$VITE_API_BASE_URL
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
# Step 5: Re-check superproject submodule pointers echo "[+] Restarting containers..."
git submodule update --remote --merge 2>/dev/null || true
# Step 6: Docker up
echo "[+] Starting Docker containers..."
docker-compose up -d docker-compose up -d
echo "[+] Cleaning up unused dangling images to free up space..."
docker image prune -f
echo "======================================" echo "======================================"
echo " NexusGuard upgrade complete! " echo " Upgrade & Rebuild complete! "
echo " API Port : 8080 " echo " Dashboard : http://localhost"
echo " API Port : ${API_PORT:-8080}"
echo "======================================" echo "======================================"