-
Notifications
You must be signed in to change notification settings - Fork 0
34 lines (31 loc) · 865 Bytes
/
Copy pathdocker-build.yml
File metadata and controls
34 lines (31 loc) · 865 Bytes
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
name: docker-build
run-name: Build Docker image and test FastAPI endpoint
on:
workflow_dispatch:
push:
paths:
- 'app/**'
jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout project repository
uses: actions/checkout@v6
- name: Build Docker image
run: docker compose up --build -d
- name: Check running containers
run: |
docker ps | grep "postgres-db"
docker ps | grep "fastapi-app"
- name: Test FastAPI endpoint
run: |
for i in {1..10}; do
echo "Attempt $i ..."
if curl -s http://localhost:8000/docs | grep "Swagger UI"; then
echo "FastAPI is ready!"
exit 0
fi
sleep 3
done
echo "FastAPI did not become ready in time."
exit 1