-
Notifications
You must be signed in to change notification settings - Fork 123
92 lines (76 loc) · 2.41 KB
/
docker-ci.yml
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
name: Docker CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
docker-build-test:
runs-on: ubuntu-latest
steps:
- name: Remove unnecessary files
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v4
- name: Remove .env copy from Dockerfile
run: sed -i '/COPY .env/d' Dockerfile
- name: Build Docker image
run: |
if ! docker build -t docetl .; then
echo "Docker build failed"
exit 1
fi
- name: Create Docker volume
run: docker volume create docetl-data
- name: Test Docker container
run: |
# Run the container in detached mode
docker run -d \
-p 3000:3000 \
-p 8000:8000 \
-v docetl-data:/docetl-data \
-e FRONTEND_HOST=0.0.0.0 \
-e FRONTEND_PORT=3000 \
-e BACKEND_HOST=0.0.0.0 \
-e BACKEND_PORT=8000 \
--name docetl-test \
docetl
# Wait for initial startup
echo "Waiting for container to start..."
sleep 30
frontend_healthy=false
# Check container health for up to 3 minutes
for i in {1..6}; do
if ! docker ps -q -f name=docetl-test > /dev/null 2>&1; then
echo "Container stopped unexpectedly"
docker logs docetl-test
exit 1
fi
# Try to curl the frontend
if curl -s -f http://localhost:3000/playground > /dev/null; then
echo "Frontend is responding"
frontend_healthy=true
break
fi
if [ $i -eq 6 ]; then
echo "Container health check failed after 3 minutes"
docker logs docetl-test
exit 1
fi
echo "Waiting for services to be ready... (attempt $i/6)"
sleep 30
done
# Explicitly fail if frontend check never succeeded
if [ "$frontend_healthy" = false ]; then
echo "Frontend health check failed"
docker logs docetl-test
exit 1
fi
# If we get here, container is running and healthy
echo "Container is running successfully"
# Cleanup
docker stop docetl-test
docker rm docetl-test
- name: Clean up Docker volume
run: docker volume rm docetl-data