Communitygithub.com

Bereitstellungsmuster

Bereitstellungsworkflows, CI/CD-Pipeline-Muster, Docker-Containerisierung, Health Checks, Rollback-Strategien und Checklisten für die Produktionsbereitschaft von Webanwendungen. Verwenden Sie dies beim Einrichten von CI/CD, Containerisieren einer App oder Überprüfen der Produktionsbereitschaft vor einem Release.

Was ist Bereitstellungsmuster?

Diese Fertigkeit bietet einen umfassenden Leitfaden für die Produktionsbereitstellung von Webanwendungen, der bewährte CI/CD-Praktiken und Bereitstellungsstrategien abdeckt. Sie hilft Entwicklern, optimale Bereitstellungsmuster wie Rolling-, Blue-Green- und Canary-Deployments auszuwählen und zu implementieren und zeigt die jeweiligen Vor- und Nachteile auf. Die Fertigkeit enthält detaillierte Multi-Stage-Dockerfile-Vorlagen für Node.js, Go und Python/Django sowie CI/CD-Pipeline-Konfigurationen für GitHub Actions, die Codequalitätsprüfungen, Builds und automatisierte Deployments umfassen. Zusätzlich werden Health-Check-Endpunkte, Kubernetes-Probes, die Validierung von Umgebungsvariablen nach dem 12-Faktor-App-Prinzip und eine umfassende Checkliste für die Produktionsbereitschaft bereitgestellt, die Anwendungs-, Infrastruktur-, Überwachungs-, Sicherheits- und Betriebsaspekte abdeckt. Die Fertigkeit ist plattformunabhängig und kann mit Docker, Kubernetes, Vercel, Railway oder anderen Bereitstellungsplattformen verwendet werden.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/deployment-patterns

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Was macht Bereitstellungsmuster?

Produktionsbereitstellungsworkflows und CI/CD-Best Practices.

Wann aktivieren

  • Einrichten von CI/CD-Pipelines
  • Dockerisieren einer Anwendung
  • Planen der Bereitstellungsstrategie (Blue-Green, Canary, Rolling)
  • Implementieren von Health Checks und Readiness Probes
  • Vorbereiten auf ein Produktionsrelease
  • Konfigurieren umgebungsspezifischer Einstellungen

Bereitstellungsstrategien

Rolling Deployment (Standard)

Instanzen schrittweise ersetzen – alte und neue Versionen laufen während des Rollouts gleichzeitig.

Instanz 1: v1 → v2  (zuerst aktualisieren)
Instanz 2: v1        (läuft noch v1)
Instanz 3: v1        (läuft noch v1)

Instanz 1: v2
Instanz 2: v1 → v2  (zweitens aktualisieren)
Instanz 3: v1

Instanz 1: v2
Instanz 2: v2
Instanz 3: v1 → v2  (zuletzt aktualisieren)

Vorteile: Null Ausfallzeit, schrittweiser Rollout Nachteile: Zwei Versionen laufen gleichzeitig – erfordert abwärtskompatible Änderungen Verwenden wenn: Standardbereitstellungen, abwärtskompatible Änderungen

Blue-Green Deployment

Zwei identische Umgebungen betreiben. Verkehr atomar umschalten.

Blue  (v1) ← Verkehr
Green (v2)   inaktiv, läuft neue Version

# Nach Überprüfung:
Blue  (v1)   inaktiv (wird Standby)
Green (v2) ← Verkehr

Vorteile: Sofortiges Rollback (zurück zu Blue), sauberer Wechsel Nachteile: Erfordert doppelte Infrastruktur während der Bereitstellung Verwenden wenn: Kritische Dienste, keine Toleranz für Probleme

Canary Deployment

Zuerst einen kleinen Prozentsatz des Verkehrs zur neuen Version leiten.

v1: 95 % des Verkehrs
v2:  5 % des Verkehrs  (Canary)

# Wenn Metriken gut aussehen:
v1: 50 % des Verkehrs
v2: 50 % des Verkehrs

# Final:
v2: 100 % des Verkehrs

Vorteile: Erkennt Probleme mit echtem Verkehr vor dem vollständigen Rollout Nachteile: Erfordert Infrastruktur zur Verkehrsaufteilung, Überwachung Verwenden wenn: Dienste mit hohem Verkehr, riskante Änderungen, Feature Flags

Docker

Multi-Stage Dockerfile (Node.js)

# Stufe 1: Abhängigkeiten installieren
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production=false

# Stufe 2: Build
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

# Stufe 3: Produktionsimage
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"]

Multi-Stage 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"]

Multi-Stage 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 Best Practices

# GUTE Praktiken
- Verwenden Sie spezifische Versions-Tags (node:22-alpine, nicht node:latest)
- Multi-Stage-Builds zur Minimierung der Image-Größe
- Als Nicht-Root-Benutzer ausführen
- Abhängigkeitsdateien zuerst kopieren (Layer-Caching)
- .dockerignore verwenden, um node_modules, .git, Tests auszuschließen
- HEALTHCHECK-Anweisung hinzufügen
- Ressourcenlimits in docker-compose oder k8s setzen

# SCHLECHTE Praktiken
- Als Root ausführen
- :latest-Tags verwenden
- Gesamtes Repository in einer COPY-Schicht kopieren
- Dev-Abhängigkeiten im Produktionsimage installieren
- Geheimnisse im Image speichern (Umgebungsvariablen oder Secrets-Manager verwenden)

CI/CD-Pipeline

GitHub Actions (Standard-Pipeline)

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: In Produktion bereitstellen
        run: |
          # Plattformspezifischer Bereitstellungsbefehl
          # Railway: railway up
          # Vercel: vercel --prod
          # K8s: kubectl set image deployment/app app=ghcr.io/${{ github.repository }}:${{ github.sha }}
          echo "Bereitstellen von ${{ github.sha }}"

Pipeline-Stufen

PR geöffnet:
  lint → typecheck → unit tests → integration tests → preview deploy

In main gemerged:
  lint → typecheck → unit tests → integration tests → build image → deploy staging → smoke tests → deploy production

Health Checks

Health Check Endpoint

// Einfacher Health Check
app.get("/health", (req, res) => {
  res.status(200).json({ status: "ok" });
});

// Detaillierter Health Check (für interne Überwachung)
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: "Datenbank nicht erreichbar" };
  }
}

Kubernetes Probes

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 maximale Startzeit

Umgebungskonfiguration

12-Faktor-App-Muster

# Alle Konfiguration über Umgebungsvariablen – niemals im Code
DATABASE_URL=postgres://user:pass@host:5432/db
REDIS_URL=redis://host:6379/0
API_KEY=${API_KEY}           # vom Secrets-Manager injiziert
LOG_LEVEL=info
PORT=3000

# Umgebungsspezifisches Verhalten
NODE_ENV=production          # oder staging, development
APP_ENV=production           # explizite App-Umgebung

Konfigurationsvalidierung

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"),
});

// Beim Start validieren – schnell fehlschlagen, wenn Konfiguration falsch ist
export const env = envSchema.parse(process.env);

Rollback-Strategie

Sofortiges Rollback

# Docker/Kubernetes: auf vorheriges Image verweisen
kubectl rollout undo deployment/app

# Vercel: vorherige Bereitstellung hochstufen
vercel rollback

# Railway: vorherigen Commit erneut bereitstellen
railway up --commit <previous-sha>

# Datenbank: Migration zurückrollen (falls umkehrbar)
npx prisma migrate resolve --rolled-back <migrationsname>

Rollback-Checkliste

  • Vorheriges Image/Artefakt ist verfügbar und getaggt
  • Datenbankmigrationen sind abwärtskompatibel (keine destruktiven Änderungen)
  • Feature Flags können neue Funktionen ohne Deployment deaktivieren
  • Überwachungsalarme für Fehlerratenspitzen konfiguriert
  • Rollback vor Produktionsrelease im Staging getestet

Checkliste für die Produktionsbereitschaft

Vor jeder Produktionsbereitstellung:

Anwendung

  • Alle Tests bestanden (Unit-, Integrations-, E2E-Tests)
  • Keine fest codierten Geheimnisse im Code oder in Konfigurationsdateien
  • Fehlerbehandlung deckt alle Randfälle ab
  • Protokollierung ist strukturiert (JSON) und enthält keine PII
  • Health Check Endpoint gibt sinnvollen Status zurück

Infrastruktur

  • Docker-Image baut reproduzierbar (festgelegte Versionen)
  • Umgebungsvariablen dokumentiert und beim Start validiert
  • Ressourcenlimits gesetzt (CPU, Arbeitsspeicher)
  • Horizontale Skalierung konfiguriert (min./max. Instanzen)
  • SSL/TLS auf allen Endpunkten aktiviert

Überwachung

  • Anwendungsmetriken exportiert (Anfragenrate, Latenz, Fehler)
  • Alarme für Fehlerrate > Schwellwert konfiguriert
  • Log-Aggregation eingerichtet (strukturierte Protokolle, durchsuchbar)
  • Verfügbarkeitsüberwachung auf Health Endpoint

Sicherheit

  • Abhängigkeiten auf CVEs gescannt
  • CORS nur für erlaubte Ursprünge konfiguriert
  • Ratenbegrenzung auf öffentlichen Endpunkten aktiviert
  • Authentifizierung und Autorisierung überprüft
  • Sicherheitsheader gesetzt (CSP, HSTS, X-Frame-Options)

Betrieb

  • Rollback-Plan dokumentiert und getestet
  • Datenbankmigration gegen produktionsgroße Daten getestet
  • Runbook für häufige Fehlerszenarien
  • Rufbereitschaftsrotation und Eskalationspfad definiert

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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

Verwandte Skills