Enhance container cleanup for zero-downtime deployment
- Add comprehensive cleanup of all portfolio-app containers - Dynamically find and remove containers with portfolio-app in name - Remove specific problematic container names (portfolio-app-new, etc.) - Add container pruning to clean up stopped containers - Ensure clean environment before starting new temporary container - Prevents any container name conflicts during deployment
This commit is contained in:
@@ -116,7 +116,20 @@ jobs:
|
|||||||
|
|
||||||
# Clean up any existing temporary containers
|
# Clean up any existing temporary containers
|
||||||
echo "🧹 Cleaning up any existing temporary containers..."
|
echo "🧹 Cleaning up any existing temporary containers..."
|
||||||
docker rm -f portfolio-app-new portfolio-app-temp-* || true
|
|
||||||
|
# Remove specific known problematic containers
|
||||||
|
docker rm -f portfolio-app-new portfolio-app-temp-* portfolio-app-backup || true
|
||||||
|
|
||||||
|
# Find and remove any containers with portfolio-app in the name (except the main one)
|
||||||
|
EXISTING_CONTAINERS=$(docker ps -a --format "table {{.Names}}" | grep "portfolio-app" | grep -v "^portfolio-app$" || true)
|
||||||
|
if [ -n "$EXISTING_CONTAINERS" ]; then
|
||||||
|
echo "🗑️ Removing existing portfolio-app containers:"
|
||||||
|
echo "$EXISTING_CONTAINERS"
|
||||||
|
echo "$EXISTING_CONTAINERS" | xargs -r docker rm -f || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Also clean up any stopped containers
|
||||||
|
docker container prune -f || true
|
||||||
|
|
||||||
# Start new container with unique temporary name (no port mapping needed for health check)
|
# Start new container with unique temporary name (no port mapping needed for health check)
|
||||||
docker run -d \
|
docker run -d \
|
||||||
|
|||||||
Reference in New Issue
Block a user