Skip to content

Commit 07ddce9

Browse files
andris9claude
andcommitted
Fix Docker networking for EmailEngine in CI
- Use explicit port mapping (-p 3000:3000) instead of host network - Use Docker bridge gateway IP (172.17.0.1) to reach Redis on host - Add container crash detection during health check - Fix HTTP code comparison to use exact string matches - Improve diagnostic logging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 996f6d1 commit 07ddce9

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

.github/workflows/tests.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,36 +150,55 @@ jobs:
150150

151151
- name: Start EmailEngine
152152
run: |
153-
# Run EmailEngine in background
153+
# Run EmailEngine in background with explicit port mapping
154154
docker run -d \
155155
--name emailengine \
156-
--network host \
157-
-e EENGINE_REDIS="redis://127.0.0.1:6379" \
156+
-p 3000:3000 \
157+
-e EENGINE_REDIS="redis://172.17.0.1:6379" \
158158
-e EENGINE_API_PROXY="false" \
159-
-e EENGINE_LOG_LEVEL="trace" \
159+
-e EENGINE_LOG_LEVEL="info" \
160160
postalsys/emailengine:latest
161161
162-
# Wait for EmailEngine to be ready (check if port 3000 is listening)
162+
# Wait for EmailEngine to be ready
163163
echo "Waiting for EmailEngine to start..."
164164
for i in {1..90}; do
165-
# Check if the server is responding (even with 401 means it's up)
166-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3000/v1/stats 2>/dev/null || echo "000")
167-
if [ "$HTTP_CODE" != "000" ]; then
165+
# Check if container is still running
166+
if ! docker ps | grep -q emailengine; then
167+
echo "EmailEngine container stopped unexpectedly!"
168+
docker logs emailengine
169+
exit 1
170+
fi
171+
172+
# Check if the server is responding
173+
if curl -sf -o /dev/null http://127.0.0.1:3000/v1/stats 2>/dev/null; then
174+
echo "EmailEngine is ready!"
175+
break
176+
fi
177+
178+
# Also accept 401/403 (means server is up but needs auth)
179+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3000/v1/stats 2>/dev/null)
180+
if [ "$HTTP_CODE" = "401" ] || [ "$HTTP_CODE" = "403" ] || [ "$HTTP_CODE" = "200" ]; then
168181
echo "EmailEngine is ready! (HTTP $HTTP_CODE)"
169182
break
170183
fi
184+
171185
if [ $i -eq 90 ]; then
172-
echo "EmailEngine failed to start"
186+
echo "EmailEngine failed to start after 3 minutes"
187+
echo "Container status:"
188+
docker ps -a
189+
echo "Container logs:"
173190
docker logs emailengine
174191
exit 1
175192
fi
176-
echo "Waiting... ($i/90)"
193+
echo "Waiting... ($i/90) - HTTP: ${HTTP_CODE:-none}"
177194
sleep 2
178195
done
179196
180-
# Show container status
197+
# Show final status
198+
echo "=== Container Status ==="
181199
docker ps
182-
docker logs emailengine | tail -20
200+
echo "=== Last 30 log lines ==="
201+
docker logs emailengine 2>&1 | tail -30
183202
184203
- name: Generate access token
185204
id: token

0 commit comments

Comments
 (0)