Files
Ten31-Portal/deploy/start.sh
T
Jonathan Kirkwood 8247c28243 Implement adjudicated DO items across backend, frontend, deploy
From the ROADMAP adjudication (12 of 13 DO items; D2 is a commit action).

Backend:
- B3: pytest suite (auth, entity CRUD, rollup) + dev deps + pytest config
- B4: cap document uploads at TEN31_MAX_UPLOAD_SIZE (default 50MB), stream-
  checked with partial-file cleanup, 413 on overflow
- B7: type AuditLog.detail as dict|list|str|None to match the JSON column
- B10: index foreign-key columns (migration a7b8c9d0e1f2 + index=True)
- B11: cli delete-user logs file-removal errors instead of swallowing them

Frontend:
- F2: distinguish "server unreachable" from "logged out"; retry prompt
- F4: confirm before destructive holdings-replace on import; step progress
- F6: expandable audit-log detail with full JSON
- F7: empty-state on the Investments page
- F8: shared role helpers (WRITER_ROLES/canEditRound/isApprover), used by
  EntitiesList, AuditLog, Import, ValuationWorkflow

Deploy:
- D5: run tsc --noEmit before packaging (build script)
- D6: TEN31_LOG_LEVEL env var (defaults to info)

Verified: 8/8 backend tests pass; alembic upgrades to head with 13 FK
indexes; upload limit rejects oversized + cleans up; frontend tsc + vite
build clean; dev server serves and proxies to the API.
2026-07-01 13:33:40 -05:00

45 lines
1.4 KiB
Bash

#!/bin/sh
set -e
# Generate session secret if not set or default
if [ "$TEN31_SESSION_SECRET" = "change-me" ]; then
if [ -f /data/.session-secret ]; then
export TEN31_SESSION_SECRET=$(cat /data/.session-secret)
else
export TEN31_SESSION_SECRET=$(python3 -c "import secrets; print(secrets.token_hex(32))")
echo "$TEN31_SESSION_SECRET" > /data/.session-secret
chmod 600 /data/.session-secret
fi
fi
# Create first approver on first boot if no users exist
if [ ! -f /data/.initialized ]; then
echo "First boot: running migrations and creating default approver..."
# Set default credentials (user can change via CLI later)
ADMIN_NAME="${TEN31_ADMIN_NAME:-Jonathan}"
ADMIN_USERNAME="${TEN31_ADMIN_USERNAME:-admin}"
ADMIN_EMAIL="${TEN31_ADMIN_EMAIL:-jonathan@ten31.xyz}"
ADMIN_PASSWORD="${TEN31_ADMIN_PASSWORD:-Ten31}"
python3 -m ten31portal.cli create-user \
--name "$ADMIN_NAME" \
--username "$ADMIN_USERNAME" \
--email "$ADMIN_EMAIL" \
--role approver \
--password "$ADMIN_PASSWORD" \
--service-admin || true
touch /data/.initialized
echo "Default approver created: username=$ADMIN_USERNAME"
fi
# Log level is overridable at runtime for debugging; defaults to info.
LOG_LEVEL="${TEN31_LOG_LEVEL:-info}"
# Serve frontend static files from the backend
exec uvicorn ten31portal.main:app \
--host 0.0.0.0 \
--port 8000 \
--log-level "$LOG_LEVEL"