Communitygithub.com

배포 패턴

웹 애플리케이션을 위한 배포 워크플로우, CI/CD 파이프라인 패턴, Docker 컨테이너화, 헬스 체크, 롤백 전략 및 프로덕션 준비 체크리스트입니다. CI/CD를 설정하거나, 앱을 컨테이너화하거나, 릴리스 전에 프로덕션 준비 상태를 확인할 때 사용하세요.

배포 패턴란 무엇인가요?

이 스킬은 웹 애플리케이션 배포의 전체 수명 주기를 다루는 포괄적인 가이드 역할을 합니다. 롤링(rolling), 블루-그린(blue-green), 카나리(canary) 배포와 같은 전략을 자세히 설명하고, 각각의 장단점과 적합한 사용 사례를 제시합니다. Node.js, Go, Python/Django를 위한 멀티 스테이지 Dockerfile 예제를 포함한 모범 사례를 제공하여 이미지 크기를 최소화하고 보안을 강화합니다. GitHub Actions 기반의 표준 CI/CD 파이프라인 예제를 통해 테스트, 빌드, 배포 단계를 자동화하는 방법을 보여줍니다. 또한, 애플리케이션 상태를 모니터링하기 위한 헬스 체크 엔드포인트, Kubernetes 프로브(liveness, readiness, startup) 설정, 12요소 앱(12-factor app) 원칙에 따른 환경 변수 구성 방법, 그리고 안전한 롤백 전략을 포함합니다. 마지막으로 프로덕션 릴리스 전에 점검해야 할 세부 체크리스트(애플리케이션, 인프라, 모니터링, 보안, 운영)를 제공하여 개발자가 안정적으로 배포할 수 있도록 돕습니다. Cursor, Codex, Claude Code 등 다양한 AI 에이전트 플랫폼에서 사용 가능합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/deployment-patterns

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

배포 패턴은(는) 무엇을 하나요?

프로덕션 배포 워크플로우와 CI/CD 모범 사례

활성화 시점

  • CI/CD 파이프라인 설정
  • 애플리케이션 Docker화
  • 배포 전략 계획 (블루-그린, 카나리, 롤링)
  • 헬스 체크 및 준비 상태 프로브 구현
  • 프로덕션 릴리스 준비
  • 환경별 설정 구성

배포 전략

롤링 배포 (기본값)

인스턴스를 점진적으로 교체합니다. 롤아웃 중에는 구 버전과 새 버전이 동시에 실행됩니다.

인스턴스 1: v1 → v2  (첫 번째 업데이트)
인스턴스 2: v1        (여전히 v1 실행 중)
인스턴스 3: v1        (여전히 v1 실행 중)

인스턴스 1: v2
인스턴스 2: v1 → v2  (두 번째 업데이트)
인스턴스 3: v1

인스턴스 1: v2
인스턴스 2: v2
인스턴스 3: v1 → v2  (마지막 업데이트)

장점: 무중단, 점진적 롤아웃 단점: 두 버전이 동시에 실행되므로 하위 호환성 유지 필요 사용 시기: 표준 배포, 하위 호환 변경

블루-그린 배포

두 개의 동일한 환경을 실행합니다. 트래픽을 원자적으로 전환합니다.

블루 (v1) ← 트래픽
그린 (v2)   유휴 상태, 새 버전 실행 중

# 확인 후:
블루 (v1)   유휴 상태 (대기 환경으로 전환)
그린 (v2) ← 트래픽

장점: 즉시 롤백 (블루로 다시 전환), 깔끔한 전환 단점: 배포 중 2배의 인프라 필요 사용 시기: 중요 서비스, 문제 발생을 허용하지 않는 경우

카나리 배포

처음에 새 버전으로 소량의 트래픽만 라우팅합니다.

v1: 95% 트래픽
v2:  5% 트래픽 (카나리)

# 메트릭이 양호하면:
v1: 50% 트래픽
v2: 50% 트래픽

# 최종:
v2: 100% 트래픽

장점: 전체 롤아웃 전에 실제 트래픽으로 문제 발견 가능 단점: 트래픽 분산 인프라와 모니터링 필요 사용 시기: 트래픽이 많은 서비스, 위험한 변경, 기능 플래그

Docker

멀티 스테이지 Dockerfile (Node.js)

# Stage 1: 종속성 설치
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production=false

# Stage 2: 빌드
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
RUN npm prune --production

# Stage 3: 프로덕션 이미지
FROM node:22-alpine AS runner
WORKDIR /app

RUN addgroup -g 1001 -S appgroup && adduser -S appuser -u 1001
USER appuser

COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules
COPY --from=builder --chown=appuser:appgroup /app/dist ./dist
COPY --from=builder --chown=appuser:appgroup /app/package.json ./

ENV NODE_ENV=production
EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1

CMD ["node", "dist/server.js"]

멀티 스테이지 Dockerfile (Go)

FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /server ./cmd/server

FROM alpine:3.19 AS runner
RUN apk --no-cache add ca-certificates
RUN adduser -D -u 1001 appuser
USER appuser

COPY --from=builder /server /server

EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:8080/health || exit 1
CMD ["/server"]

멀티 스테이지 Dockerfile (Python/Django)

FROM python:3.12-slim AS builder
WORKDIR /app
RUN pip install --no-cache-dir uv
COPY requirements.txt .
RUN uv pip install --system --no-cache -r requirements.txt

FROM python:3.12-slim AS runner
WORKDIR /app

RUN useradd -r -u 1001 appuser
USER appuser

COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY . .

ENV PYTHONUNBUFFERED=1
EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=3s CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/')" || exit 1
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "4"]

Docker 모범 사례

# 좋은 관행
- 특정 버전 태그 사용 (node:22-alpine, node:latest 아님)
- 이미지 크기를 최소화하는 멀티 스테이지 빌드
- 루트가 아닌 사용자로 실행
- 종속성 파일 먼저 복사 (레이어 캐싱)
- .dockerignore를 사용하여 node_modules, .git, 테스트 제외
- HEALTHCHECK 지시문 추가
- docker-compose 또는 k8s에서 리소스 제한 설정

# 나쁜 관행
- 루트로 실행
- :latest 태그 사용
- 전체 리포지토리를 한 번에 복사
- 프로덕션 이미지에 개발 종속성 설치
- 이미지에 비밀 정보 저장 (환경 변수 또는 비밀 관리자 사용)

CI/CD 파이프라인

GitHub Actions (표준 파이프라인)

name: CI/CD

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run lint
      - run: npm run typecheck
      - run: npm test -- --coverage
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: coverage
          path: coverage/

  build:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v4
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v5
        with:
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
          cache-from: type=gha
          cache-to: type=gha,mode=max

  deploy:
    needs: build
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    environment: production
    steps:
      - name: 프로덕션에 배포
        run: |
          # 플랫폼별 배포 명령어
          # Railway: railway up
          # Vercel: vercel --prod
          # K8s: kubectl set image deployment/app app=ghcr.io/${{ github.repository }}:${{ github.sha }}
          echo "${{ github.sha }} 배포 중"

파이프라인 단계

PR이 열림:
  lint → typecheck → 단위 테스트 → 통합 테스트 → 미리보기 배포

main에 병합됨:
  lint → typecheck → 단위 테스트 → 통합 테스트 → 이미지 빌드 → 스테이징 배포 → 스모크 테스트 → 프로덕션 배포

헬스 체크

헬스 체크 엔드포인트

// 간단한 헬스 체크
app.get("/health", (req, res) => {
  res.status(200).json({ status: "ok" });
});

// 상세 헬스 체크 (내부 모니터링용)
app.get("/health/detailed", async (req, res) => {
  const checks = {
    database: await checkDatabase(),
    redis: await checkRedis(),
    externalApi: await checkExternalApi(),
  };

  const allHealthy = Object.values(checks).every(c => c.status === "ok");

  res.status(allHealthy ? 200 : 503).json({
    status: allHealthy ? "ok" : "degraded",
    timestamp: new Date().toISOString(),
    version: process.env.APP_VERSION || "unknown",
    uptime: process.uptime(),
    checks,
  });
});

async function checkDatabase(): Promise<HealthCheck> {
  try {
    await db.query("SELECT 1");
    return { status: "ok", latency_ms: 2 };
  } catch (err) {
    return { status: "error", message: "Database unreachable" };
  }
}

Kubernetes 프로브

livenessProbe:
  httpGet:
    path: /health
    port: 3000
  initialDelaySeconds: 10
  periodSeconds: 30
  failureThreshold: 3

readinessProbe:
  httpGet:
    path: /health
    port: 3000
  initialDelaySeconds: 5
  periodSeconds: 10
  failureThreshold: 2

startupProbe:
  httpGet:
    path: /health
    port: 3000
  initialDelaySeconds: 0
  periodSeconds: 5
  failureThreshold: 30    # 30 * 5s = 150s 최대 시작 시간

환경 구성

12요소 앱 패턴

# 모든 구성은 환경 변수를 통해 - 코드에 절대 포함되지 않음
DATABASE_URL=postgres://user:pass@host:5432/db
REDIS_URL=redis://host:6379/0
API_KEY=${API_KEY}           # 비밀 관리자에 의해 주입됨
LOG_LEVEL=info
PORT=3000

# 환경별 동작
NODE_ENV=production          # 또는 staging, development
APP_ENV=production           # 명시적 앱 환경

구성 검증

import { z } from "zod";

const envSchema = z.object({
  NODE_ENV: z.enum(["development", "staging", "production"]),
  PORT: z.coerce.number().default(3000),
  DATABASE_URL: z.string().url(),
  REDIS_URL: z.string().url(),
  JWT_SECRET: z.string().min(32),
  LOG_LEVEL: z.enum(["debug", "info", "warn", "error"]).default("info"),
});

// 시작 시 검증 - 구성이 잘못되면 빠르게 실패
const env = envSchema.parse(process.env);

롤백 전략

즉시 롤백

# Docker/Kubernetes: 이전 이미지를 가리키기
kubectl rollout undo deployment/app

# Vercel: 이전 배포를 승격
vercel rollback

# Railway: 이전 커밋 재배포
railway up --commit <previous-sha>

# Database: 마이그레이션 롤백 (되돌릴 수 있는 경우)
npx prisma migrate resolve --rolled-back <migration-name>

롤백 체크리스트

  • 이전 이미지/아티팩트를 사용할 수 있고 태그가 지정되어 있는가?
  • 데이터베이스 마이그레이션이 하위 호환 가능한가? (파괴적 변경 없음)
  • 기능 플래그가 배포 없이 새 기능을 비활성화할 수 있는가?
  • 오류율 급증에 대한 모니터링 알림이 구성되어 있는가?
  • 프로덕션 릴리스 전에 스테이징에서 롤백이 테스트되었는가?

프로덕션 준비 체크리스트

프로덕션 배포 전에:

애플리케이션

  • 모든 테스트 통과 (단위, 통합, E2E)
  • 코드나 구성 파일에 하드코딩된 비밀 정보 없음
  • 오류 처리가 모든 엣지 케이스를 다룸
  • 로깅이 구조화되어 있고 (JSON) PII를 포함하지 않음
  • 헬스 체크 엔드포인트가 의미 있는 상태를 반환함

인프라

  • Docker 이미지가 재현 가능하게 빌드됨 (버전 고정)
  • 환경 변수가 문서화되고 시작 시 검증됨
  • 리소스 제한 설정 (CPU, 메모리)
  • 수평적 확장 구성 (최소/최대 인스턴스)
  • 모든 엔드포인트에서 SSL/TLS 활성화

모니터링

  • 애플리케이션 메트릭 내보내기 (요청 속도, 지연 시간, 오류)
  • 오류율이 임계값을 초과할 때 알림 구성
  • 로그 집계 설정 (구조화된 로그, 검색 가능)
  • 헬스 엔드포인트에 대한 가동 시간 모니터링

보안

  • CVE에 대한 종속성 스캔
  • 허용된 출처만을 위해 CORS 구성
  • 공개 엔드포인트에 속도 제한 활성화
  • 인증 및 권한 부여 확인
  • 보안 헤더 설정 (CSP, HSTS, X-Frame-Options)

운영

  • 롤백 계획 문서화 및 테스트 완료
  • 프로덕션 규모의 데이터에 대해 데이터베이스 마이그레이션 테스트
  • 일반적인 장애 시나리오에 대한 실행 설명서
  • 온콜 로테이션 및 에스컬레이션 경로 정의

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

관련 스킬