Przejdź do treści
Biblioteka skilli
DevOps i chmura · Budowanie i kod

docker-deploy

/docker-deploy

Pomaga tworzyć Dockerfile i konfiguracje docker-compose oraz konteneryzować aplikacje: buildy wieloetapowe, optymalizacja obrazów, wzorce compose dla dev i produkcji, healthchecki, obsługa sygnałów i utwardzanie.

Repozytorium
claude-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
25.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
6
Przestarzałość

Brak sygnałów. Repozytorium zmienione 25.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pomaga tworzyć Dockerfile i konfiguracje docker-compose oraz konteneryzować aplikacje: buildy wieloetapowe, optymalizacja obrazów, wzorce compose dla dev i produkcji, healthchecki, obsługa sygnałów i utwardzanie.

Oryginalny opis (EN)

Use when creating Dockerfiles, docker-compose configs, or containerizing applications. Covers multi-stage builds, image optimization, compose patterns for dev and production, health checks, signal handling, and security hardening.

Jak działa

  1. Quick Reference
  2. Dockerfile Templates
  3. Docker Compose Patterns
  4. .dockerignore
  5. Image Optimization
  6. Health Checks
  7. Signal Handling
  8. Security Hardening
  9. Anti-Patterns
Sekcje z nagłówków SKILL.md, w oryginale · 284 linii, 900 słów
Podgląd SKILL.md
---
name: docker-deploy
description: Use when creating Dockerfiles, docker-compose configs, or containerizing applications. Covers multi-stage builds, image optimization, compose patterns for dev and production, health checks, signal handling, and security hardening.
---

# Docker and Deployment Patterns

## Quick Reference

| Task | Approach |
|------|----------|
| New Dockerfile | Choose template by language below |
| Optimize image | Multi-stage build + Alpine/distroless base |
| Dev environment | docker-compose with hot-reload and volumes |
| Production | Multi-stage, non-root user, health checks |
| Debugging | `docker logs`, `docker exec`, build with `--progress=plain` |

## Dockerfile Templates

### Python (FastAPI / Flask / Django)

```dockerfile
# Build stage -- check https://hub.docker.com/_/python for latest
FROM python:3.13-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt

# Runtime stage
FROM python:3.13-slim
WORKDIR /app
RUN adduser --disabled-password --no-create-home appuser
COPY --from=builder /install /usr/local
COPY . .
USER appuser
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```

### Node.js (Express / Next.js / Vite)

```dockerfile
# Build stage -- check https://hub.docker.com/_/node for latest LTS
FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY . .
RUN pnpm build

# Runtime stage
FROM node:22-alpine
WORKDIR /app
RUN adduser -D appuser
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json .
USER appuser
EXPOSE 3000
CMD ["node", "dist/index.js"]
```

### Go

```dockerfile
# Build stage -- check https://hub.docker.com/_/golang for latest
FROM golang:1.23-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/server .

# Runtime stage
FROM gcr.io/distroless/static-debian12
COPY --from=builder /app/server /server
USER nonroot
EXPOSE 8080
ENTRYPOINT ["/server"]
```

### Rust

```dockerfile
# Build stage -- check https://hub.docker.com/_/rust for latest
FROM rust:1.82-slim AS builder
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src
COPY . .
RUN cargo build --release

# Runtime stage
FROM gcr.io/distroless/cc-debian12
COPY --from=builder /app/target/release/app /app
USER nonroot
EXPOSE 8080
ENTRYPOINT ["/app"]
```

## Docker Compose Patterns

### Development

```yaml
services:
  app:
    build: .
    ports:
      - "8000:8000"
    volumes:
      - .:/app          # Hot-reload via volume mount
      - /app/node_modules  # Exclude node_modules from mount
    environment:
      - DEBUG=true
    depends_on:
      db:
        condition: service_healthy

  db:
    image: mongo:8
    ports:
      - "27017:27017"
    volumes:
      - db_data:/data/db
    healthcheck:
      test: mongosh --eval "db.runCommand('ping').ok"
      interval: 10s
      timeout: 5s
      retries: 3

volumes:
  db_data:
```

### Production

```yaml
services:
  app:
    image: ghcr.io/org/app:latest
    ports:
      - "8000:8000"
    env_file: .env
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 512M
          cpus: "0.5"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 15s
    depends_on:
      db:
        condition: service_healthy

  db:
    image: mongo:8
    volumes:
      - db_data:/data/db
    restart: unless-stopped
    healthcheck:
      test: mongosh --eval "db.runCommand('ping').ok"
      interval: 30s
      timeout: 10s
      retries: 3

volumes:
  db_data:
```

## .dockerignore

Always create a `.dockerignore` to keep images small and avoid leaking secrets:

```
.git
.gitignore
node_modules
__pycache__
*.pyc
.env
.env.*
.vscode
.idea
*.md
!README.md
docker-compose*.yml
Dockerfile*
.dockerignore
tests/
coverage/
.pytest_cache/
dist/
build/
```

## Image Optimization

### Base Image Selection

| Use Case | Base Image | Size |
|----------|-----------|------|
| Python apps | `python:<version>-slim` | ~150MB |
| Python minimal | `python:<version>-alpine` | ~50MB |
| Node.js apps | `node:<lts>-alpine` | ~130MB |
| Go apps | `gcr.io/distroless/static` | ~2MB |
| Rust apps | `gcr.io/distroless/cc` | ~20MB |
| Static files | `nginx:alpine` | ~40MB |

### Layer Caching

Order instructions from least to most frequently changing:

```dockerfile
# 1. Base image (rarely changes)
FROM python:3.13-slim

# 2. System deps (rarely changes)
RUN apt-get update && apt-get install -y --no-install-recommends curl

# 3. App deps (changes when lockfile changes)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 4. App code (changes most often - LAST)
COPY . .
```

## Health Checks

```dockerfile
# HTTP health check
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=15s \
  CMD curl -f http://localhost:8000/health || exit 1

# TCP health check (no curl needed)
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
  CMD nc -z localhost 8000 || exit 1
```

## Signal Handling

Use `exec` form for CMD/ENTRYPOINT to receive signals correctly:

```dockerfile
# GOOD: exec form - PID 1, receives SIGTERM
CMD ["uvicorn", "main:app", "--host", "0.0.0.0"]

# BAD: shell form - shell is PID 1, app doesn't get signals
CMD uvicorn main:app --host 0.0.0.0
```

For Node.js, handle SIGTERM explicitly:
```javascript
process.on("SIGTERM", () => {
  server.close(() => process.exit(0));
});
```

## Security Hardening

| Practice | Implementation |
|----------|---------------|
| Non-root user | `RUN adduser -D appuser` + `USER appuser` |
| No secrets in image | Use env vars or mounted secrets at runtime |
| Pin base image digests | `FROM python:3.13-slim@sha256:abc...` for production |
| Scan for vulnerabilities | `docker scout cves` or `trivy image` |
| Read-only filesystem | `docker run --read-only --tmpdir /tmp` |
| No unnecessary packages | `--no-install-recommends` for apt |

## Anti-Patterns

| Don't | Do Instead |
|-------|-----------|
| Run as root | Create and switch to non-root user |
| Skip `.dockerignore` | Always create one (prevents leaking .env, .git) |
| `COPY . .` before installing deps | Copy lockfile first, install, then copy code |
| Use `latest` tag in production | Pin specific versions or digests |
| Store secrets in image layers | Use runtime env vars or mounted secrets |
| Install dev dependencies in prod image | Use multi-stage builds |
| Use `alpine` with Python C extensions | Use `slim` instead (musl vs glibc issues) |
| Ignore `SIGTERM` handling | Use exec form CMD + signal handlers |

Wersje

RepozytoriumWynikLicencja
Ta strona · sagargupta16/claude-skills100MIT
wrongstack/wrongstack100MIT

Migawka bazy z 28.10.2026 · wersja paczki 64ff3ae67c0f (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100devops-docker-patterns
    Pomaga w konteneryzacji Docker: wieloetapowe buildy, optymalizacja obrazów, wzorce Docker Compose i bezpieczeństwo kontenerów produkcyjnych.
  • 100docker
    Pomaga konteneryzować aplikacje: Dockerfile, obrazy, budowanie wieloetapowe, rozmiar obrazu, warstwy i bezpieczeństwo kontenerów.
  • 100docker-development
    Pomaga konteneryzować usługi PHP, Python, JavaScript i API: Dockerfile, obrazy wieloetapowe, Compose, buildy w CI, uprawnienia uruchomieniowe i trwałe zależności.
  • 95docker-patterns
    Pomaga pisać Dockerfile i Compose: multi-stage build, użytkownicy nieuprzywilejowani, cache warstw i rozdział dev od produkcji.
  • 100docker-patterns
    Dostarcza wzorce Docker i Docker Compose: budowanie wieloetapowe, sieci, wolumeny i konfiguracje produkcyjne.
  • 100docker
    Wspiera konteneryzację aplikacji: wieloetapowe Dockerfile, Docker Compose, cache warstw i bezpieczeństwo kontenerów, a także optymalizację obrazów.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.