Local dev stack improvements

- Extend docker-compose.dev.yml with optional monitoring profile
  (Prometheus, Grafana, Loki) via --profile monitoring
- Align dev PostgreSQL with production: pg_stat_statements + init scripts
- Add scripts/seed.ts with idempotent Berlin test data (user, route, activity)
- Add pnpm db:seed and pnpm dev:reset scripts
- Simplify CI e2e job: replace manual docker run + BRouter setup with
  docker compose up --wait; add db:seed step
- Improve scripts/dev.sh: Docker check, --wait health checks, --monitoring
  flag, seed step
- Add scripts/reset-dev.sh to wipe and restart the local stack
- Add .env.development.example with documented local defaults

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-05-17 20:49:06 +02:00
parent d7b3c7c1a5
commit 10e0a8d41a
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
10 changed files with 209 additions and 105 deletions

View file

@ -6,50 +6,59 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"
# Parse flags
MONITORING=false
for arg in "$@"; do
case "$arg" in
--monitoring) MONITORING=true ;;
esac
done
# Check Docker is running
if ! docker info > /dev/null 2>&1; then
echo "Error: Docker is not running. Please start Docker and try again."
exit 1
fi
echo "=== trails.cool dev environment ==="
echo ""
# 1. Start Docker services
echo "Starting Docker services..."
docker compose -f docker-compose.dev.yml up -d
if [ "$MONITORING" = "true" ]; then
echo "Starting Docker services (with monitoring)..."
docker compose -f docker-compose.dev.yml --profile monitoring up -d --wait
else
echo "Starting Docker services..."
docker compose -f docker-compose.dev.yml up -d --wait
fi
echo "✓ Services are ready"
# 2. Wait for PostgreSQL
echo "Waiting for PostgreSQL..."
until docker compose -f docker-compose.dev.yml exec -T postgres pg_isready -U trails > /dev/null 2>&1; do
sleep 1
done
echo "✓ PostgreSQL is ready"
# 3. Push database schema
# 2. Push database schema
echo "Pushing database schema..."
pnpm db:push 2>&1 | tail -3
echo "✓ Database schema up to date"
# 3. Seed database
echo "Seeding database..."
pnpm db:seed
echo "✓ Database seeded"
# 4. Download BRouter segments if needed
echo "Checking BRouter segments..."
"$SCRIPT_DIR/download-dev-segments.sh"
# 5. Wait for BRouter (if segments are available)
if docker compose -f docker-compose.dev.yml ps brouter --format '{{.State}}' 2>/dev/null | grep -q "running"; then
echo "Waiting for BRouter..."
for i in $(seq 1 30); do
if curl -sf http://localhost:17777/brouter?lonlats=13.4,52.5\|13.5,52.5\&profile=trekking\&format=geojson > /dev/null 2>&1; then
echo "✓ BRouter is ready"
break
fi
if [ "$i" = "30" ]; then
echo "⚠ BRouter not responding (segments may still be loading). Continuing..."
fi
sleep 2
done
fi
echo ""
echo "=== Starting apps ==="
echo " Journal: http://localhost:3000"
echo " Planner: http://localhost:3001"
echo " BRouter: http://localhost:17777"
if [ "$MONITORING" = "true" ]; then
echo " Grafana: http://localhost:3002"
echo " Prometheus: http://localhost:9090"
fi
echo ""
echo " Tip: pnpm dev:reset to wipe all data and start fresh"
echo ""
# 6. Start both apps with turbo
# 5. Start both apps with turbo
exec pnpm dev