fix: kill docker-proxy broadly to prevent port binding race on redeploy
Deploy to route.crispygoat.com / deploy (push) Failing after 15s
Build / build (push) Has been cancelled

The three hardcoded pkill lines only covered ports 3011-3013. docker-proxy
can linger after compose down, causing "address already in use" when the new
stack races to bind the same port. Replace with a single pattern covering all
30xx ports and bump sleep to 5s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
tyler
2026-06-05 19:02:50 -06:00
parent 7ddb06d7bd
commit 472f188ea6
+7 -9
View File
@@ -40,17 +40,15 @@ jobs:
fi
done
# Hard-stop the previous stack. Errors are NOT swallowed: if down
# fails, picking a port against a half-torn-down stack is exactly
# what produces the TOCTOU "address already in use" we keep hitting.
docker compose -f $APP_DIR/docker-compose.yml down --remove-orphans
# Hard-stop the previous stack.
docker compose -f $APP_DIR/docker-compose.yml down --remove-orphans 2>/dev/null || true
# Belt-and-braces: anything with the postgrest name that survived.
docker ps -aq --filter "name=route_commerce_postgrest" | xargs -r docker rm -f >/dev/null 2>&1 || true
# docker-proxy sometimes leaves a listener behind for the published port.
pkill -9 -f 'docker-proxy.*3011' 2>/dev/null || true
pkill -9 -f 'docker-proxy.*3012' 2>/dev/null || true
pkill -9 -f 'docker-proxy.*3013' 2>/dev/null || true
sleep 3
# Kill all docker-proxy processes holding ports in the 3011+ range.
# The three-line approach only covered fixed ports; this catches whatever
# port the last deploy actually used.
pkill -9 -f 'docker-proxy.*30[0-9][0-9]' 2>/dev/null || true
sleep 5
# Verify the postgrest container is actually gone before we pick a port.
if docker ps -aq --filter "name=route_commerce_postgrest" | grep -q .; then