Fix port conflict in zero-downtime deployment
Some checks failed
CI/CD Pipeline (Zero Downtime) / production (push) Failing after 7m49s
CI/CD Pipeline (Simple) / production (push) Has been cancelled

- Remove port mapping for temporary container to avoid conflicts
- Use docker exec for health checks instead of external port access
- Eliminates 'port already allocated' error
- Maintains zero-downtime functionality without port conflicts
This commit is contained in:
2025-09-13 01:13:43 +02:00
parent 8d627028cb
commit 89e0f9f2f8

View File

@@ -109,12 +109,11 @@ jobs:
if [ "$CURRENT_CONTAINER_RUNNING" = "true" ]; then if [ "$CURRENT_CONTAINER_RUNNING" = "true" ]; then
echo "🔄 Performing rolling update..." echo "🔄 Performing rolling update..."
# Start new container with temporary name # Start new container with temporary name (no port mapping needed for health check)
docker run -d \ docker run -d \
--name portfolio-app-new \ --name portfolio-app-new \
--restart unless-stopped \ --restart unless-stopped \
--network portfolio_net \ --network portfolio_net \
-p 3001:3000 \
-e NODE_ENV=${{ vars.NODE_ENV }} \ -e NODE_ENV=${{ vars.NODE_ENV }} \
-e LOG_LEVEL=${{ vars.LOG_LEVEL }} \ -e LOG_LEVEL=${{ vars.LOG_LEVEL }} \
-e DATABASE_URL=postgresql://portfolio_user:portfolio_pass@postgres:5432/portfolio_db?schema=public \ -e DATABASE_URL=postgresql://portfolio_user:portfolio_pass@postgres:5432/portfolio_db?schema=public \
@@ -133,9 +132,9 @@ jobs:
echo "⏳ Waiting for new container to be ready..." echo "⏳ Waiting for new container to be ready..."
sleep 15 sleep 15
# Health check new container # Health check new container using docker exec
for i in {1..20}; do for i in {1..20}; do
if curl -f http://localhost:3001/api/health > /dev/null 2>&1; then if docker exec portfolio-app-new curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
echo "✅ New container is healthy!" echo "✅ New container is healthy!"
break break
fi fi