#!/usr/bin/env bash # # Build/setup script for Prism v2. # # Prepares backend and frontend dependencies and builds the frontend so the # stack is ready to run. This script does NOT install systemd or nginx, restart # services, or manage git hooks. # # Usage: # ./scripts/deploy.sh # ./scripts/deploy.sh --help set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" APP_DIR="${APP_DIR:-$(cd "$SCRIPT_DIR/.." && pwd)}" PYTHON_BIN="${PYTHON_BIN:-python3}" BACKEND_VENV="$APP_DIR/backend/.venv" usage() { sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//' exit 0 } for arg in "$@"; do case "$arg" in -h|--help) usage ;; *) echo "Unknown arg: $arg" >&2; exit 2 ;; esac done log() { printf '\n=== %s ===\n' "$*"; } if [[ ! -d "$APP_DIR/backend" || ! -d "$APP_DIR/frontend" ]]; then echo "Expected repo root at $APP_DIR (backend/ + frontend/ not found)" >&2 exit 1 fi log "Backend: venv + dependencies" if [[ ! -x "$BACKEND_VENV/bin/pip" ]]; then "$PYTHON_BIN" -m venv "$BACKEND_VENV" fi "$BACKEND_VENV/bin/pip" install --quiet --upgrade pip "$BACKEND_VENV/bin/pip" install --quiet -r "$APP_DIR/backend/requirements.txt" log "Frontend: npm ci + build" npm --prefix "$APP_DIR/frontend" ci npm --prefix "$APP_DIR/frontend" run build log "Build complete" cat <