#!/bin/bash # velobase-harness deployment script — runs ON the server set -e cd /root # Clone if not exists if [ ! -d velobase-harness ]; then echo "[1] Cloning repo..." git clone --depth 1 https://ghfast.top/https://github.com/velobase/velobase-harness.git 2>&1 || \ git clone --depth 1 https://github.com/velobase/velobase-harness.git 2>&1 fi cd velobase-harness echo "[2] Creating .env..." 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:5432/velobase POSTGRES_PORT=5432 REDIS_URL=redis://localhost:6379 REDIS_PORT=6379 SKIP_MIGRATION=false MIGRATION_OPTIONAL=false SKIP_SEED=true SEED_OPTIONAL=true ENVEOF echo " .env created ($(wc -l < .env) lines)" echo "[3] Pulling images..." docker pull postgres:16 2>&1 | tail -3 docker pull redis:7 2>&1 | tail -3 echo "[4] Starting postgres+redis..." docker compose up -d postgres redis 2>&1 | tail -3 echo "[5] Building Docker image (takes 5-15 min)..." docker build -t velobase-app . 2>&1 | tail -5 echo "[6] 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 "[7] Verification..." sleep 5 docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1 | grep -E "velobase|postgres|redis" echo "---" curl -s -o /dev/null -w "HTTP %{http_code}" --max-time 10 http://localhost:3000/ 2>&1 || echo "APP NOT YET READY"