37 lines
1.6 KiB
Bash
Executable File
37 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# StemEngine startup script.
|
|
# Builds the React frontend (full build, then watch mode) and starts the
|
|
# FastAPI backend. Both processes run in the same container so that
|
|
# .tsx/.ts edits on the host are picked up and served without a Docker rebuild.
|
|
|
|
set -e
|
|
|
|
FRONTEND=/app/frontend
|
|
BACKEND=/app/backend
|
|
|
|
echo "========================================="
|
|
echo " StemEngine startup"
|
|
echo "========================================="
|
|
|
|
# ── Frontend ──────────────────────────────────────────────────────────────────
|
|
cd "$FRONTEND"
|
|
|
|
# Install / sync packages. --prefer-offline uses the local cache first so
|
|
# subsequent starts are fast; falls back to the registry if needed.
|
|
echo "[frontend] Syncing npm packages..."
|
|
npm install --prefer-offline --no-audit --no-fund 2>&1 | grep -v "^npm warn" || true
|
|
|
|
# Initial full build so backend/static is populated before uvicorn starts.
|
|
# Subsequent hot-rebuilds are handled by --watch below.
|
|
echo "[frontend] Building..."
|
|
npx vite build 2>&1
|
|
|
|
echo "[frontend] Starting watch mode (rebuilds on .tsx/.ts changes)..."
|
|
npx vite build --watch 2>&1 &
|
|
|
|
# ── Backend ───────────────────────────────────────────────────────────────────
|
|
cd /app
|
|
echo "[backend] Starting uvicorn..."
|
|
exec python3.11 -m uvicorn backend.main:app \
|
|
--host 0.0.0.0 --port 8000 --log-level debug --reload
|