$npx -y skills add affaan-m/ECC --skill deployment-patternsDeployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications. Use when setting up deployment infrastructure or planning releases.
| 1 | # Deployment Patterns |
| 2 | |
| 3 | Production deployment workflows and CI/CD best practices. |
| 4 | |
| 5 | ## When to Activate |
| 6 | |
| 7 | - Setting up CI/CD pipelines |
| 8 | - Dockerizing an application |
| 9 | - Planning deployment strategy (blue-green, canary, rolling) |
| 10 | - Implementing health checks and readiness probes |
| 11 | - Preparing for a production release |
| 12 | - Configuring environment-specific settings |
| 13 | |
| 14 | ## Deployment Strategies |
| 15 | |
| 16 | ### Rolling Deployment (Default) |
| 17 | |
| 18 | Replace instances gradually — old and new versions run simultaneously during rollout. |
| 19 | |
| 20 | ``` |
| 21 | Instance 1: v1 → v2 (update first) |
| 22 | Instance 2: v1 (still running v1) |
| 23 | Instance 3: v1 (still running v1) |
| 24 | |
| 25 | Instance 1: v2 |
| 26 | Instance 2: v1 → v2 (update second) |
| 27 | Instance 3: v1 |
| 28 | |
| 29 | Instance 1: v2 |
| 30 | Instance 2: v2 |
| 31 | Instance 3: v1 → v2 (update last) |
| 32 | ``` |
| 33 | |
| 34 | **Pros:** Zero downtime, gradual rollout |
| 35 | **Cons:** Two versions run simultaneously — requires backward-compatible changes |
| 36 | **Use when:** Standard deployments, backward-compatible changes |
| 37 | |
| 38 | ### Blue-Green Deployment |
| 39 | |
| 40 | Run two identical environments. Switch traffic atomically. |
| 41 | |
| 42 | ``` |
| 43 | Blue (v1) ← traffic |
| 44 | Green (v2) idle, running new version |
| 45 | |
| 46 | # After verification: |
| 47 | Blue (v1) idle (becomes standby) |
| 48 | Green (v2) ← traffic |
| 49 | ``` |
| 50 | |
| 51 | **Pros:** Instant rollback (switch back to blue), clean cutover |
| 52 | **Cons:** Requires 2x infrastructure during deployment |
| 53 | **Use when:** Critical services, zero-tolerance for issues |
| 54 | |
| 55 | ### Canary Deployment |
| 56 | |
| 57 | Route a small percentage of traffic to the new version first. |
| 58 | |
| 59 | ``` |
| 60 | v1: 95% of traffic |
| 61 | v2: 5% of traffic (canary) |
| 62 | |
| 63 | # If metrics look good: |
| 64 | v1: 50% of traffic |
| 65 | v2: 50% of traffic |
| 66 | |
| 67 | # Final: |
| 68 | v2: 100% of traffic |
| 69 | ``` |
| 70 | |
| 71 | **Pros:** Catches issues with real traffic before full rollout |
| 72 | **Cons:** Requires traffic splitting infrastructure, monitoring |
| 73 | **Use when:** High-traffic services, risky changes, feature flags |
| 74 | |
| 75 | ## Docker |
| 76 | |
| 77 | ### Multi-Stage Dockerfile (Node.js) |
| 78 | |
| 79 | ```dockerfile |
| 80 | # Stage 1: Install dependencies |
| 81 | FROM node:22-alpine AS deps |
| 82 | WORKDIR /app |
| 83 | COPY package.json package-lock.json ./ |
| 84 | RUN npm ci --production=false |
| 85 | |
| 86 | # Stage 2: Build |
| 87 | FROM node:22-alpine AS builder |
| 88 | WORKDIR /app |
| 89 | COPY --from=deps /app/node_modules ./node_modules |
| 90 | COPY . . |
| 91 | RUN npm run build |
| 92 | RUN npm prune --production |
| 93 | |
| 94 | # Stage 3: Production image |
| 95 | FROM node:22-alpine AS runner |
| 96 | WORKDIR /app |
| 97 | |
| 98 | RUN addgroup -g 1001 -S appgroup && adduser -S appuser -u 1001 |
| 99 | USER appuser |
| 100 | |
| 101 | COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules |
| 102 | COPY --from=builder --chown=appuser:appgroup /app/dist ./dist |
| 103 | COPY --from=builder --chown=appuser:appgroup /app/package.json ./ |
| 104 | |
| 105 | ENV NODE_ENV=production |
| 106 | EXPOSE 3000 |
| 107 | |
| 108 | HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ |
| 109 | CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1 |
| 110 | |
| 111 | CMD ["node", "dist/server.js"] |
| 112 | ``` |
| 113 | |
| 114 | ### Multi-Stage Dockerfile (Go) |
| 115 | |
| 116 | ```dockerfile |
| 117 | FROM golang:1.22-alpine AS builder |
| 118 | WORKDIR /app |
| 119 | COPY go.mod go.sum ./ |
| 120 | RUN go mod download |
| 121 | COPY . . |
| 122 | RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /server ./cmd/server |
| 123 | |
| 124 | FROM alpine:3.19 AS runner |
| 125 | RUN apk --no-cache add ca-certificates |
| 126 | RUN adduser -D -u 1001 appuser |
| 127 | USER appuser |
| 128 | |
| 129 | COPY --from=builder /server /server |
| 130 | |
| 131 | EXPOSE 8080 |
| 132 | HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:8080/health || exit 1 |
| 133 | CMD ["/server"] |
| 134 | ``` |
| 135 | |
| 136 | ### Multi-Stage Dockerfile (Python/Django) |
| 137 | |
| 138 | ```dockerfile |
| 139 | FROM python:3.12-slim AS builder |
| 140 | WORKDIR /app |
| 141 | RUN pip install --no-cache-dir uv |
| 142 | COPY requirements.txt . |
| 143 | RUN uv pip install --system --no-cache -r requirements.txt |
| 144 | |
| 145 | FROM python:3.12-slim AS runner |
| 146 | WORKDIR /app |
| 147 | |
| 148 | RUN useradd -r -u 1001 appuser |
| 149 | USER appuser |
| 150 | |
| 151 | COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages |
| 152 | COPY --from=builder /usr/local/bin /usr/local/bin |
| 153 | COPY . . |
| 154 | |
| 155 | ENV PYTHONUNBUFFERED=1 |
| 156 | EXPOSE 8000 |
| 157 | |
| 158 | HEALTHCHECK --interval=30s --timeout=3s CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/')" || exit 1 |
| 159 | CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "4"] |
| 160 | ``` |
| 161 | |
| 162 | ### Docker Best Practices |
| 163 | |
| 164 | ``` |
| 165 | # GOOD practices |
| 166 | - Use specific version tags (node:22-alpine, not node:latest) |
| 167 | - Multi-stage builds to minimize image size |
| 168 | - Run as non-root user |
| 169 | - Copy dependency files first (layer caching) |
| 170 | - Use .dockerignore to exclude node_modules, .git, tests |
| 171 | - Add HEALTHCHECK instruction |
| 172 | - Set resource limits in docker-compose or k8s |
| 173 | |
| 174 | # BAD practices |
| 175 | - Running as root |
| 176 | - Using :latest tags |
| 177 | - Copying entire repo in one COPY layer |
| 178 | - Installing dev dependencies in production image |
| 179 | - Storing secrets in image (use env vars or secrets manager) |
| 180 | ``` |
| 181 | |
| 182 | ## CI/CD Pipeline |
| 183 | |
| 184 | ### GitHub Actions (Standard Pipeline) |
| 185 | |
| 186 | ```yaml |
| 187 | name: CI/CD |
| 188 | |
| 189 | on: |
| 190 | push: |
| 191 | branches: [main] |
| 192 | pull_ |