feat: add --frontend-server flag for server-side builds

Builds frontend on server (91.98.224.44) instead of locally.
Recommended for low-RAM machines where Vite builds hang.

- Added DEPLOY_FRONTEND_SERVER variable
- Added --frontend-server CLI flag
- Updated --all to use server build by default
- Server build: git pull → pnpm install → pnpm build → rsync to /var/www/
This commit is contained in:
kempersc 2026-01-16 14:17:46 +01:00
parent 77fb2ba9bf
commit bbef8eeac3

View file

@ -6,7 +6,8 @@
# Options: # Options:
# --infra Deploy infrastructure changes (Terraform) # --infra Deploy infrastructure changes (Terraform)
# --data Deploy ontologies directly to Oxigraph (no intermediate storage) # --data Deploy ontologies directly to Oxigraph (no intermediate storage)
# --frontend Build and deploy frontend (bronhouder.nl) # --frontend Build locally and deploy frontend (bronhouder.nl) - SLOW on low-RAM machines
# --frontend-server Build on server and deploy frontend (RECOMMENDED)
# --archief Build and deploy archief-assistent (archief.support) # --archief Build and deploy archief-assistent (archief.support)
# --api Deploy FastAPI backend (DSPy SPARQL generation) # --api Deploy FastAPI backend (DSPy SPARQL generation)
# --ducklake Deploy DuckLake API backend # --ducklake Deploy DuckLake API backend
@ -68,12 +69,13 @@ DEPLOY_DUCKLAKE=false
DEPLOY_QDRANT=false DEPLOY_QDRANT=false
DEPLOY_VALKEY=false DEPLOY_VALKEY=false
DEPLOY_RAG=false DEPLOY_RAG=false
DEPLOY_FRONTEND_SERVER=false
CLEAR_OXIGRAPH=false CLEAR_OXIGRAPH=false
STATUS_ONLY=false STATUS_ONLY=false
SYNC_REVIEWS=false SYNC_REVIEWS=false
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo "Usage: $0 [--infra] [--data] [--frontend] [--archief] [--api] [--ducklake] [--qdrant] [--valkey] [--rag] [--all] [--status] [--clear] [--sync-reviews]" echo "Usage: $0 [--infra] [--data] [--frontend] [--frontend-server] [--archief] [--api] [--ducklake] [--qdrant] [--valkey] [--rag] [--all] [--status] [--clear] [--sync-reviews]"
exit 1 exit 1
fi fi
@ -88,6 +90,9 @@ for arg in "$@"; do
--frontend) --frontend)
DEPLOY_FRONTEND=true DEPLOY_FRONTEND=true
;; ;;
--frontend-server)
DEPLOY_FRONTEND_SERVER=true
;;
--archief) --archief)
DEPLOY_ARCHIEF=true DEPLOY_ARCHIEF=true
;; ;;
@ -112,7 +117,7 @@ for arg in "$@"; do
--all) --all)
DEPLOY_INFRA=true DEPLOY_INFRA=true
DEPLOY_DATA=true DEPLOY_DATA=true
DEPLOY_FRONTEND=true DEPLOY_FRONTEND_SERVER=true # Use server build (faster, recommended)
DEPLOY_ARCHIEF=true DEPLOY_ARCHIEF=true
DEPLOY_API=true DEPLOY_API=true
DEPLOY_DUCKLAKE=true DEPLOY_DUCKLAKE=true
@ -277,7 +282,7 @@ if [ -z "$SERVER_IP" ]; then
fi fi
# Wait for SSH (needed for all deployment operations) # Wait for SSH (needed for all deployment operations)
if [ "$DEPLOY_DATA" = true ] || [ "$DEPLOY_FRONTEND" = true ] || [ "$DEPLOY_ARCHIEF" = true ] || [ "$DEPLOY_API" = true ] || [ "$DEPLOY_DUCKLAKE" = true ] || [ "$DEPLOY_QDRANT" = true ] || [ "$DEPLOY_RAG" = true ]; then if [ "$DEPLOY_DATA" = true ] || [ "$DEPLOY_FRONTEND" = true ] || [ "$DEPLOY_FRONTEND_SERVER" = true ] || [ "$DEPLOY_ARCHIEF" = true ] || [ "$DEPLOY_API" = true ] || [ "$DEPLOY_DUCKLAKE" = true ] || [ "$DEPLOY_QDRANT" = true ] || [ "$DEPLOY_RAG" = true ]; then
wait_for_ssh "$SERVER_IP" wait_for_ssh "$SERVER_IP"
fi fi
@ -552,6 +557,49 @@ if [ "$DEPLOY_FRONTEND" = true ]; then
echo -e "${GREEN}Frontend deployment complete${NC}" echo -e "${GREEN}Frontend deployment complete${NC}"
fi fi
# Deploy frontend (server-side build - recommended for low-RAM machines)
if [ "$DEPLOY_FRONTEND_SERVER" = true ]; then
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Building Frontend on Server (Recommended)${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
# Push local changes first
echo -e "${YELLOW}Pushing local changes to git...${NC}"
cd "$PROJECT_ROOT"
git push origin master 2>&1 || echo " (Nothing to push or push failed - continuing anyway)"
# Build on server
echo -e "${YELLOW}Building on server (pulling, installing, building, deploying)...${NC}"
ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" << 'ENDSSH'
set -e
cd /opt/glam
# Pull latest changes
echo "Pulling latest changes..."
git pull origin master
# Install dependencies if needed
echo "Installing dependencies..."
pnpm install --frozen-lockfile 2>/dev/null || pnpm install
# Build frontend
echo "Building frontend..."
cd frontend
pnpm build
# Deploy to production
echo "Deploying to /var/www/glam-frontend/..."
rsync -av --delete dist/ /var/www/glam-frontend/
echo "Build and deployment complete!"
ENDSSH
cd "$PROJECT_ROOT"
echo -e "${GREEN}Server-side frontend deployment complete${NC}"
fi
# Deploy archief-assistent (archief.support) # Deploy archief-assistent (archief.support)
if [ "$DEPLOY_ARCHIEF" = true ]; then if [ "$DEPLOY_ARCHIEF" = true ]; then
echo "" echo ""