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
|
fi
|
||||||
done
|
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
|
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.
|
# Remove the network explicitly so Docker allocates a fresh subnet.
|
||||||
docker ps -aq --filter "name=route_commerce_postgrest" | xargs -r docker rm -f >/dev/null 2>&1 || true
|
docker network rm route-commerce_default 2>/dev/null || true
|
||||||
# Kill all docker-proxy processes holding ports in the 3011+ range.
|
sleep 3
|
||||||
# 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.
|
# Verify all route-commerce containers are gone before picking a port.
|
||||||
if docker ps -aq --filter "name=route_commerce_postgrest" | grep -q .; then
|
REMAINING=$(docker ps -aq --filter "name=route_commerce_" --filter "name=route-commerce-" | wc -l)
|
||||||
echo "ERROR: route_commerce_postgrest still running after down"
|
if [ "$REMAINING" -gt 0 ]; then
|
||||||
docker ps --filter "name=route_commerce_postgrest"
|
echo "ERROR: $REMAINING route-commerce container(s) still running after teardown"
|
||||||
|
docker ps --filter "name=route_commerce_" --filter "name=route-commerce-"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user