-
Notifications
You must be signed in to change notification settings - Fork 1
111 lines (92 loc) · 3.52 KB
/
docker-test-dev.yml
File metadata and controls
111 lines (92 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Docker Dev Test
on:
pull_request:
branches: [dev, main]
push:
branches: [dev]
workflow_dispatch:
jobs:
test-dev:
name: Test Docker Dev Environment
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create .env file
run: |
cp .env.development.example .env
echo "Created .env from development example"
- name: Validate docker-compose configurations
run: |
echo "Validating base configuration..."
cd infra
docker-compose -f docker-compose.yml config > /dev/null
echo "Validating dev configuration..."
docker-compose -f docker-compose.yml -f docker-compose.dev.yml config > /dev/null
echo "✓ All configurations valid"
- name: Build Docker images
run: |
cd infra
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --no-cache
- name: Start services
run: |
cd infra
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d mongo redis qdrant api
echo "Services started"
- name: Wait for services to be healthy
run: |
echo "Waiting for services to be healthy..."
timeout 120 bash -c '
while true; do
if docker ps --filter "name=sbd-mongo" --filter "health=healthy" | grep -q sbd-mongo && \
docker ps --filter "name=sbd-redis" --filter "health=healthy" | grep -q sbd-redis && \
docker ps --filter "name=sbd-qdrant" --filter "health=healthy" | grep -q sbd-qdrant && \
docker ps --filter "name=sbd-api" --filter "health=healthy" | grep -q sbd-api; then
echo "All services are healthy!"
break
fi
echo "Waiting for services..."
sleep 5
done
'
- name: Show service status
run: |
cd infra
docker-compose ps
- name: Test API health endpoint
run: |
echo "Testing API health endpoint..."
curl -f http://localhost:8000/health || exit 1
echo "✓ API is responding"
- name: Test API docs endpoint
run: |
echo "Testing API docs endpoint..."
curl -f http://localhost:8000/docs || exit 1
echo "✓ API docs are accessible"
- name: Run basic connectivity tests
run: |
echo "Testing MongoDB connectivity..."
docker exec sbd-mongo mongosh --eval "db.runCommand({ ping: 1 })" --quiet
echo "Testing Redis connectivity..."
docker exec sbd-redis redis-cli ping
echo "✓ All services are accessible"
- name: Show logs on failure
if: failure()
run: |
cd infra
echo "=== API Logs ==="
docker-compose logs --tail=100 api
echo "=== MongoDB Logs ==="
docker-compose logs --tail=50 mongo
echo "=== Redis Logs ==="
docker-compose logs --tail=50 redis
echo "=== Qdrant Logs ==="
docker-compose logs --tail=50 qdrant
- name: Cleanup
if: always()
run: |
cd infra
docker-compose -f docker-compose.yml -f docker-compose.dev.yml down -v --remove-orphans
docker system prune -f