ailixir-api / .github /workflows /md-simulation-health.yml
AILIXIR Bot
Auto-sync: 111e815272130800a3fe964fa998478820680ada
7922c7a
Raw
History Blame Contribute Delete
3.53 kB
name: MD Simulation Health Check
on:
push:
branches: [MD-integration]
workflow_dispatch:
concurrency:
group: md-simulation-health-${{ github.ref }}
cancel-in-progress: true
jobs:
md-simulation-health-check:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Laravel image
run: docker build -t ailixir-laravel .
- name: Build MD simulation image
run: docker build -t md-simulation ai_apps/Protein-Ligand-MD-Simulation/
- name: Create Docker network
run: docker network create ailixir-md
- name: Start Laravel API
run: |
docker run -d --name ailixir-laravel \
--network ailixir-md \
-p 8000:8000 \
--env-file docker/laravel.env \
-e MD_SIMULATION_URL=http://md-api:5005 \
ailixir-laravel
- name: Start Redis
run: |
docker run -d --name md-redis \
--network ailixir-md \
--network-alias md-redis \
redis:7-alpine
- name: Start MD Simulation API
run: |
docker run -d --name md-api \
--network ailixir-md \
-p 5005:5005 \
-e REDIS_HOST=md-redis \
-e REDIS_PORT=6379 \
-e USE_REDIS=true \
-e OPENMM_PLATFORM=CPU \
-e FLASK_HOST=0.0.0.0 \
-e FLASK_PORT=5005 \
-e MD_DATA_DIR=/app/data \
-e LOG_LEVEL=INFO \
md-simulation
- name: Wait for Laravel API to be ready
run: |
echo "Waiting for Laravel API to be ready..."
for i in $(seq 1 30); do
if curl -sf http://localhost:8000/ > /dev/null 2>&1; then
echo "Laravel API is ready"
exit 0
fi
echo "Waiting for Laravel ($i/30)..."
sleep 2
done
docker logs ailixir-laravel
exit 1
- name: Wait for MD Simulation API to be healthy
run: |
echo "Waiting for MD Simulation API to be healthy..."
for i in $(seq 1 60); do
if curl -sf http://localhost:5005/health > /dev/null 2>&1; then
echo "MD Simulation API is healthy"
exit 0
fi
echo "Waiting for MD API ($i/60)..."
sleep 5
done
docker logs md-api
exit 1
- name: Test MD simulation health via Laravel proxy
run: |
echo "GET /api/md-simulation/health via Laravel proxy"
RESPONSE=$(curl -sf http://localhost:8000/api/md-simulation/health)
echo "$RESPONSE"
STATUS=$(echo "$RESPONSE" | python3 -c "import json,sys; print(json.load(sys.stdin).get('status'))")
if [ "$STATUS" != "ok" ]; then
echo "Expected status 'ok', got '$STATUS'"
exit 1
fi
echo "MD Simulation service is healthy via Laravel proxy!"
- name: Dump logs on failure
if: failure()
run: |
docker logs ailixir-laravel || true
docker logs md-api || true
docker logs md-redis || true
- name: Cleanup
if: always()
run: |
docker rm -f ailixir-laravel md-api md-redis 2>/dev/null || true
docker network rm ailixir-md 2>/dev/null || true