This skill guides Dockerfile best practices, security hardening, and multi-stage builds to optimize images and reduce risk.
npx playbooks add skill yldgio/codereview-skills --skill docker
--build-arg to prevent injection attacks. Validate and escape externally-sourced values before using in ARG, ENV, or LABEL directives{{ }} and undeclared variables in Dockerfiles. Add linting step to scan for these patterns during reviewUSER directive)--privileged without justificationreadonly root filesystem where possiblelatest)alpine, slim, distroless)RUN commands to reduce layers.dockerignore to exclude unnecessary files, sensitive data, and build artifacts like node_modulesCOPY instead of ADD (unless extracting archives)WORKDIR before COPY/RUNEXPOSE for documentationLABEL metadataSHELL if bash/sh features are neededENV for configuration (not secrets)apt-get clean)ENTRYPOINT vs CMD: use ENTRYPOINT for main command, CMD for default argsorg.opencontainers.image.*)HEALTHCHECK instruction# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
# Runtime stage
FROM node:20-alpine
# Add OCI labels for documentation
LABEL org.opencontainers.image.title="My App"
LABEL org.opencontainers.image.description="Production web application"
LABEL org.opencontainers.image.version="1.0.0"
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
# Copy dependencies and app files
COPY --from=builder /app/node_modules ./node_modules
COPY . .
# Set environment variables (not secrets)
ENV NODE_ENV=production
USER appuser
EXPOSE 3000
HEALTHCHECK CMD wget -q --spider http://localhost:3000/health || exit 1
# Use ENTRYPOINT for main command, CMD for default args
ENTRYPOINT ["node"]
CMD ["server.js"]Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.