docker
Dockerfile best practices, security hardening, multi-stage builds, and image optimization
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Dockerfile best practices, security hardening, multi-stage builds, and image optimization
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Angular component architecture, RxJS patterns, change detection, and module organization
Azure DevOps pipeline security, YAML structure, variable management, and deployment patterns
Azure Bicep IaC patterns, parameterization, security, and modular design
ASP.NET Core patterns, dependency injection, middleware, async/await, and security
FastAPI endpoint design, Pydantic validation, dependency injection, and async patterns
GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line.
| name | docker |
| description | Dockerfile best practices, security hardening, multi-stage builds, and image optimization |
| metadata | {"version":"1.1.0"} |
--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"]