一键导入
docker-deploy
Use when containerizing applications, writing Dockerfiles, creating docker-compose configs, or setting up CI/CD deployment pipelines
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when containerizing applications, writing Dockerfiles, creating docker-compose configs, or setting up CI/CD deployment pipelines
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use when designing, building, or reviewing REST/GraphQL APIs — covers endpoint design, error handling, versioning, authentication, and documentation
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Use when you have an implementation plan to execute, or when facing 2+ independent tasks/bugs — supports sequential execution, parallel dispatch (if available), and single-agent fallback
Use when reviewing code for security issues, handling secrets, setting up authentication, auditing dependencies, or before deploying to production
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
基于 SOC 职业分类
| name | docker-deploy |
| description | Use when containerizing applications, writing Dockerfiles, creating docker-compose configs, or setting up CI/CD deployment pipelines |
Containers should be small, secure, and reproducible.
Core principle: Immutable builds, minimal images, environment parity.
# Stage 1: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production && cp -R node_modules /prod_modules
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: Production
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /prod_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY package.json ./
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["node", "dist/index.js"]
| ✅ Do | ❌ Don't |
|---|---|
Use alpine or slim base images | Use full ubuntu / node:latest |
COPY package*.json first (layer cache) | COPY . . before npm install |
npm ci (deterministic) | npm install (non-deterministic) |
USER node (non-root) | Run as root |
| Multi-stage builds | Single stage with dev deps |
.dockerignore file | Copy node_modules / .git |
Pin versions (node:20.11-alpine) | Use latest tag |
HEALTHCHECK instruction | No health checks |
node_modules
.git
.env
*.md
.github
coverage
dist
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "${PORT:-3000}:3000"
environment:
- NODE_ENV=production
- DATABASE_URL=${DATABASE_URL}
depends_on:
db:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
cpus: "0.5"
db:
image: postgres:16-alpine
volumes:
- pgdata:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
volumes:
pgdata:
depends_on with condition: service_healthyrestart: unless-stopped for productionlimitsvolumes for persistent data.env file for secrets (never hardcode)${VAR:-default} syntax for defaultsname: Build & Deploy
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build -t app:${{ github.sha }} .
- name: Run tests
run: docker run --rm app:${{ github.sha }} npm test
- name: Push to registry
run: |
docker tag app:${{ github.sha }} $REGISTRY/app:${{ github.sha }}
docker tag app:${{ github.sha }} $REGISTRY/app:latest
docker push $REGISTRY/app --all-tags
.dockerignore exists and is completedocker scout, trivy)| Technique | Typical Savings |
|---|---|
alpine base | 500MB → 50MB |
| Multi-stage build | Remove dev deps, build tools |
.dockerignore | Exclude .git, node_modules, docs |
npm ci --only=production | No dev dependencies |
| Pin + minimal layers | Better cache, smaller diff |