Files
sino-mci/scripts/local-up.sh
marsal 51a373e06c chore: consolidate docker-compose and add integration tests
- Merge infrastructure/docker-compose.yml + docker-compose.app.yml into root docker-compose.yml with profiles (infra/app).
- Add healthchecks for mysql/redis/rabbitmq/mci-server/channel-service and depends_on conditions.
- Rewrite scripts/local-up.sh to use profiles and wait for healthy states.
- Add curl to mci-server and channel-service Docker images for healthchecks.
- Add npm test script to admin-web (type-check + build smoke test).
- Add scripts/test-external-api.sh covering 11 API endpoints.
- Verify Java (7/7), Python (6/6), npm build, external API (11/11), and UI flows.
2026-07-07 13:35:41 +08:00

61 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/.."
wait_for_healthy() {
local service=$1
local max_retries=${2:-60}
local retry_count=0
local container_name
echo "Waiting for $service to become healthy..."
while [ "$retry_count" -lt "$max_retries" ]; do
container_name=$(docker compose --profile infra --profile app ps -q "$service" 2>/dev/null | head -n1)
if [ -n "$container_name" ]; then
local status
status=$(docker inspect --format='{{.State.Health.Status}}' "$container_name" 2>/dev/null || true)
if [ "$status" = "healthy" ]; then
echo "$service is healthy."
return 0
fi
fi
retry_count=$((retry_count + 1))
sleep 2
done
echo "$service did not become healthy within $((max_retries * 2)) seconds."
docker compose --profile infra --profile app logs --tail=50 "$service"
return 1
}
echo "Starting infrastructure services..."
docker compose --profile infra up -d
wait_for_healthy mysql 60
wait_for_healthy redis 30
wait_for_healthy rabbitmq 60
echo "Infrastructure is ready."
echo "MySQL: jdbc:mysql://localhost:3306/sino_mci"
echo "Redis: localhost:6379"
echo "RabbitMQ: localhost:5672 / http://localhost:15672"
echo "SeaweedFS: http://localhost:9333"
if [ "$1" == "--with-apps" ]; then
echo "Starting application services..."
# Include infra profile so that depends_on conditions can resolve.
docker compose --profile infra --profile app up -d --build
wait_for_healthy mci-server 90
wait_for_healthy channel-service 60
echo "Application services are ready."
echo "Admin Web: http://localhost"
echo "Backend API: http://localhost:8080/msg-platform"
echo "Channel Service: http://localhost:8000"
fi