#!/bin/bash # Deploy velobase-harness - Part 2: fix ports + start + build + run set -e cd /root/velobase-harness # Clean up any failed containers docker compose down 2>/dev/null || true # Update .env with non-conflicting ports cat > .env << 'ENVEOF' NEXT_PUBLIC_APP_ENV=dev NEXT_PUBLIC_APP_NAME=Velobase NEXT_PUBLIC_SUPPORT_EMAIL=admin@example.com NEXT_PUBLIC_DISABLE_TEST_LOGIN=true APP_URL=http://210.16.161.214:3000 SERVICE_MODE=web,worker NEXTAUTH_SECRET=velobase-dev-secret-key-change-in-prod AUTH_URL=http://210.16.161.214:3000 DATABASE_URL=postgresql://velobase:velobase@localhost:5433/velobase POSTGRES_PORT=5433 REDIS_URL=redis://localhost:6380 REDIS_PORT=6380 SKIP_MIGRATION=false MIGRATION_OPTIONAL=false SKIP_SEED=true SEED_OPTIONAL=true ENVEOF echo "=== .env updated with ports 5433/6380 ===" cat .env echo "" echo "=== Starting postgres:5433 + redis:6380 ===" docker compose up -d postgres redis 2>&1 echo "" echo "=== Container status ===" docker compose ps 2>&1 echo "" echo "=== Building Docker image ===" docker build -t velobase-app . 2>&1 | tail -10 echo "" echo "=== Starting app container ===" docker rm -f velobase-app 2>/dev/null || true docker run -d --name velobase-app \ --restart unless-stopped \ --network host \ --env-file /root/velobase-harness/.env \ -v /root/velobase-harness/logs:/app/logs \ velobase-app 2>&1 echo "" echo "=== Verification (wait 10s) ===" sleep 10 docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1 echo "" echo "=== HTTP Check ===" curl -s -o /dev/null -w "HTTP %{http_code}" --max-time 10 http://localhost:3000/ 2>&1 || echo "APP NOT READY YET" echo "" echo "=== Latest logs ===" docker logs velobase-app --tail 20 2>&1 || echo "no logs yet"