← ClaudeAtlas

docker-patternslisted

Provides Docker and containerization best practices including multi-stage builds, security hardening, and compose patterns. Use when writing Dockerfiles, optimizing images, setting up containers, or when user mentions 'Docker', 'container', 'Dockerfile', 'docker-compose', 'image'.
Tibsfox/gsd-skill-creator · ★ 61 · AI & Automation · score 74
Install: claude install-skill Tibsfox/gsd-skill-creator
# Docker Patterns Best practices for building secure, efficient, and production-ready Docker images and compositions. ## Multi-Stage Builds Multi-stage builds separate build dependencies from runtime, producing smaller and more secure images. ### Node.js / TypeScript ```dockerfile # Stage 1: Install dependencies FROM node:20-alpine AS deps WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci --ignore-scripts # Stage 2: Build FROM node:20-alpine AS build WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build RUN npm prune --production # Stage 3: Production FROM node:20-alpine AS production WORKDIR /app RUN addgroup -g 1001 appgroup && \ adduser -u 1001 -G appgroup -s /bin/sh -D appuser COPY --from=build --chown=appuser:appgroup /app/dist ./dist COPY --from=build --chown=appuser:appgroup /app/node_modules ./node_modules COPY --from=build --chown=appuser:appgroup /app/package.json ./ USER appuser 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/index.js"] ``` ### Python ```dockerfile # Stage 1: Build FROM python:3.12-slim AS build WORKDIR /app RUN python -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . # Stage 2: Production FROM python:3.12-slim AS production WORKDIR /app RUN groupadd -r appgroup