Enhance container cleanup for zero-downtime deployment
Some checks failed
CI/CD Pipeline (Zero Downtime) / production (push) Failing after 7m57s
CI/CD Pipeline (Simple) / production (push) Failing after 7m54s

- 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:
2025-09-13 18:21:36 +02:00
parent 20a6c416e3
commit 65ad26eeae

View File

@@ -116,7 +116,20 @@ jobs:
# Clean 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)
docker run -d \