kirche-einfach/.devcontainer/setup.sh

63 lines
1.8 KiB
Bash

#!/bin/bash
set -e
echo "=== Setting up kirche-einfach ==="
# Backend
echo "--- Installing Python dependencies ---"
cd /workspaces/kirche-einfach/backend
uv sync
# Frontend
echo "--- Installing Node dependencies ---"
cd /workspaces/kirche-einfach/frontend
npm install
# Compose services (langflow, lfx) must be up; fail loudly otherwise.
echo "--- Waiting for compose services ---"
if [ ! -f /workspaces/kirche-einfach/.env ]; then
echo "ERROR: /workspaces/kirche-einfach/.env is missing. Copy .env.example to .env and fill in secrets." >&2
exit 1
fi
python3 - <<'EOF'
import socket
import sys
import time
targets = [("langflow", 7860), ("lfx", 6004)]
deadline = time.time() + 180
pending = dict(targets)
while pending and time.time() < deadline:
for host, port in list(pending):
s = socket.socket()
s.settimeout(2)
try:
s.connect((host, port))
print(f"OK {host}:{port}", flush=True)
del pending[(host, port)]
except OSError:
pass
finally:
s.close()
if pending:
time.sleep(2)
if pending:
sys.exit(f"ERROR: compose services not ready: {sorted(pending)}")
EOF
# Migrate the SQLite schema and reconcile backend/flows into the DB + LFX.
echo "--- Migrating database ---"
cd /workspaces/kirche-einfach/backend
uv run alembic upgrade head
echo "--- Syncing canonical flows ---"
uv run python scripts/sync_flows.py --sync || echo "WARN: flow sync failed (check backend/flows and LFX)"
echo ""
echo "=== Setup complete ==="
echo "Forgejo username: $FORGEJO_USERNAME"
# Hand dirs back to vscode (this script runs via sudo; uv/npm create caches as root)
chown -R vscode:vscode /workspaces/kirche-einfach/backend/.venv \
/workspaces/kirche-einfach/frontend/node_modules \
/home/vscode/.cache 2>/dev/null || true