#!/usr/bin/env bash # build-single-binary.sh — produce bin/agent-server with embedded web/dist set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT" info() { printf '\033[1;34m[build-single-binary]\033[0m %s\n' "$*"; } SHA="$(git rev-parse --short HEAD)" OUT="${OUT_BIN:-$ROOT/bin/agent-server}" info "building web/dist (demo seeds OFF)..." ( cd "$ROOT/web" if [[ ! -d node_modules ]]; then npm ci fi env -u VITE_ENABLE_DEMO_SEEDS npm run build ) if [[ ! -f "$ROOT/web/dist/index.html" ]]; then echo "missing web/dist/index.html after build" >&2 exit 1 fi info "go build → $OUT (embed web/dist @ $SHA)..." mkdir -p "$(dirname "$OUT")" CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${SHA}" -o "$OUT" ./cmd/server info "done: $OUT ($(du -h "$OUT" | awk '{print $1}'))" info "next: LOCALPG_MODE=managed PI_AGENT_RUNNER_URL=http://127.0.0.1:18865 $OUT" info " or ./scripts/launch.sh --no-docker"