From 65ad26eeaeb51e58368dd8e3f50c4c97e8f9f1c1 Mon Sep 17 00:00:00 2001 From: denshooter Date: Sat, 13 Sep 2025 18:21:36 +0200 Subject: [PATCH] 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 --- .gitea/workflows/ci-cd.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index 3ec275b..5daba6e 100644 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -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 \