Skip to content

Commit 1134cfa

Browse files
committed
Use docker compose --wait for Kafka startup
Replace the custom bash readiness loop with `docker compose ... up -d --wait` in CI and PR workflows. This simplifies startup of the microservices-messaging Kafka service and removes the manual retry/polling logic. Files changed: .github/workflows/maven-ci.yml, .github/workflows/maven-pr-builder.yml. Note: requires a Docker Compose version that supports the `--wait` flag.
1 parent 2bf401c commit 1134cfa

2 files changed

Lines changed: 2 additions & 30 deletions

File tree

.github/workflows/maven-ci.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,7 @@ jobs:
4343

4444
# Start Kafka Docker Service for microservices-messaging
4545
- name: Start Kafka Docker Service
46-
run: docker compose -f microservices-messaging/docker-compose.yml up -d
47-
48-
- name: Wait for Kafka Readiness
49-
run: |
50-
retry=0
51-
until docker exec kafka-messaging-demo kafka-topics --bootstrap-server localhost:9092 --list 2>/dev/null || [ $retry -eq 20 ]; do
52-
echo "[INFO] Waiting for Kafka to become ready on port 9092..."
53-
sleep 2
54-
retry=$((retry+1))
55-
done
56-
if [ $retry -eq 20 ]; then
57-
echo "[ERROR] Kafka did not become ready within timeout."
58-
exit 1
59-
fi
60-
echo "[INFO] Kafka is ready!"
46+
run: docker compose -f microservices-messaging/docker-compose.yml up -d --wait
6147

6248
# Some tests need screen access
6349
- name: Install xvfb

.github/workflows/maven-pr-builder.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,7 @@ jobs:
3535
3636
# Start Kafka Docker Service for microservices-messaging
3737
- name: Start Kafka Docker Service
38-
run: docker compose -f microservices-messaging/docker-compose.yml up -d
39-
40-
- name: Wait for Kafka Readiness
41-
run: |
42-
retry=0
43-
until docker exec kafka-messaging-demo kafka-topics --bootstrap-server localhost:9092 --list 2>/dev/null || [ $retry -eq 20 ]; do
44-
echo "[INFO] Waiting for Kafka to become ready on port 9092..."
45-
sleep 2
46-
retry=$((retry+1))
47-
done
48-
if [ $retry -eq 20 ]; then
49-
echo "[ERROR] Kafka did not become ready within timeout."
50-
exit 1
51-
fi
52-
echo "[INFO] Kafka is ready!"
38+
run: docker compose -f microservices-messaging/docker-compose.yml up -d --wait
5339

5440
# Some tests need screen access
5541
- name: Install xvfb

0 commit comments

Comments
 (0)