Fix port conflict in zero-downtime deployment
- 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:
@@ -109,12 +109,11 @@ jobs:
|
||||
if [ "$CURRENT_CONTAINER_RUNNING" = "true" ]; then
|
||||
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 \
|
||||
--name portfolio-app-new \
|
||||
--restart unless-stopped \
|
||||
--network portfolio_net \
|
||||
-p 3001:3000 \
|
||||
-e NODE_ENV=${{ vars.NODE_ENV }} \
|
||||
-e LOG_LEVEL=${{ vars.LOG_LEVEL }} \
|
||||
-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..."
|
||||
sleep 15
|
||||
|
||||
# Health check new container
|
||||
# Health check new container using docker exec
|
||||
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!"
|
||||
break
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user