---
name: ecc-deployment-patterns
description: Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.
---

# Deployment Patterns

Deployment workflows and CI/CD patterns for web applications.

## When to Activate
- Setting up CI/CD for a project
- Writing deployment scripts
- Planning rollback strategy
- Reviewing production readiness

## CI/CD Pipeline

### Stages
1. **Lint** — formatting, type checking
2. **Test** — unit, integration, e2e
3. **Build** — compile, bundle, Docker image
4. **Deploy** — push to staging/production

### Deployment Strategies
| Strategy | Downtime | Risk | Complexity |
|----------|----------|------|------------|
| Blue-green | None | Low | Medium |
| Rolling | None | Medium | Medium |
| Canary | None | Low | High |
| Recreate | Full | Low | Low |

## Health Checks
```yaml
# Docker Compose healthcheck
healthcheck:
  test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
  interval: 30s
  timeout: 10s
  retries: 3
  start_period: 10s
```

## Rollback Strategy
- **Kubernetes**: `kubectl rollout undo deployment/app`
- **Docker**: `docker compose up -d app:previous_tag`
- **Git-based**: `git revert HEAD && git push`

## Production Checklist
- [ ] Environment variables via secrets manager
- [ ] Health check endpoint
- [ ] Graceful shutdown (SIGTERM handler)
- [ ] Logging to stdout (not files)
- [ ] Metrics endpoint (prometheus)
- [ ] Rate limiting on auth routes
- [ ] Database connection pooling
- [ ] CORS properly configured
- [ ] TLS/SSL enabled
