fix: tear down all route-commerce containers by name before redeploy
docker compose down was silently failing (|| true) when the compose file was stale, leaving db/minio running on the old network subnet. The new postgrest container then couldn't bind because Docker tried to reuse the same subnet with conflicting container IPs. Now: rm -f all containers matching route_commerce_/route-commerce- by name first (works regardless of compose file state), then remove the network explicitly so Docker allocates a clean subnet on the next up. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+11
-12
@@ -40,20 +40,19 @@ jobs:
|
||||
fi
|
||||
done
|
||||
|
||||
# Hard-stop the previous stack.
|
||||
# Hard-stop the previous stack by name — works even if docker-compose.yml
|
||||
# is missing or stale from a prior failed deploy.
|
||||
docker ps -aq --filter "name=route_commerce_" --filter "name=route-commerce-" | xargs -r docker rm -f 2>/dev/null || true
|
||||
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
|
||||
# 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
|
||||
# Remove the network explicitly so Docker allocates a fresh subnet.
|
||||
docker network rm route-commerce_default 2>/dev/null || true
|
||||
sleep 3
|
||||
|
||||
# Verify the postgrest container is actually gone before we pick a port.
|
||||
if docker ps -aq --filter "name=route_commerce_postgrest" | grep -q .; then
|
||||
echo "ERROR: route_commerce_postgrest still running after down"
|
||||
docker ps --filter "name=route_commerce_postgrest"
|
||||
# Verify all route-commerce containers are gone before picking a port.
|
||||
REMAINING=$(docker ps -aq --filter "name=route_commerce_" --filter "name=route-commerce-" | wc -l)
|
||||
if [ "$REMAINING" -gt 0 ]; then
|
||||
echo "ERROR: $REMAINING route-commerce container(s) still running after teardown"
|
||||
docker ps --filter "name=route_commerce_" --filter "name=route-commerce-"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user