#!/bin/bash # llmindex.io — deploy script (run ON the node, e.g. m3u96b, from the app dir) # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai # License: Proprietary — © Simon-Pierre Boucher, all rights reserved # # m3u96b is macOS: process management is PM2 (see infra/ecosystem.config.cjs); # the systemd units in infra/systemd/ are the Linux-host equivalent. # Code arrives via `git pull --ff-only origin main` when a remote exists, # otherwise via rsync from the workstation (current setup). set -euo pipefail APP_DIR="${APP_DIR:-/srv/llmindex}" cd "$APP_DIR" if git rev-parse --git-dir >/dev/null 2>&1 && git remote get-url origin >/dev/null 2>&1; then git pull --ff-only origin main fi pnpm install --frozen-lockfile pnpm --filter @llmindex/db generate pnpm build # Standalone output needs static assets + public dir alongside server.js STANDALONE="apps/web/.next/standalone/apps/web" mkdir -p "$STANDALONE/.next" rsync -a --delete apps/web/.next/static/ "$STANDALONE/.next/static/" if [ -d apps/web/public ]; then rsync -a apps/web/public/ "$STANDALONE/public/"; fi # Prisma query engine is not traced into the standalone bundle (pnpm layout) — # copy the generated .prisma client next to where the runtime searches for it. PRISMA_SRC=$(ls -d node_modules/.pnpm/@prisma+client*/node_modules/.prisma 2>/dev/null | head -1) if [ -n "$PRISMA_SRC" ]; then PRISMA_DEST="apps/web/.next/standalone/$(dirname "$PRISMA_SRC")" mkdir -p "$PRISMA_DEST" cp -R "$PRISMA_SRC" "$PRISMA_DEST/" fi pnpm db:migrate:deploy pm2 startOrReload infra/ecosystem.config.cjs --update-env pm2 save sleep 3 curl -fsS http://127.0.0.1:3100/api/v1/health >/dev/null && echo "✓ local health OK" curl -fsS https://www.llmindex.io/api/v1/health >/dev/null && echo "✓ tunnel health OK (www.llmindex.io)"