Ревью Dockerfile
Пишет и проверяет Dockerfile: закреплённые базовые образы, multi-stage, порядок слоёв для кеша, не-root пользователь, .dockerignore. Используйте при создании или ревью Dockerfile и образов.
dockerfile-reviewУстановка
Выполните одну команду — она сохранит SKILL.md в папку скиллов агента. Перезапустите агента, и он подхватит скилл сам.
mkdir -p ~/.claude/skills/dockerfile-review && curl -fsSL https://anymodel.org/en/skills/devops/dockerfile-review/SKILL.md -o ~/.claude/skills/dockerfile-review/SKILL.md
mkdir -p ~/.agents/skills/dockerfile-review && curl -fsSL https://anymodel.org/en/skills/devops/dockerfile-review/SKILL.md -o ~/.agents/skills/dockerfile-review/SKILL.md
New-Item -ItemType Directory -Force "$HOME\.claude\skills\dockerfile-review" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/devops/dockerfile-review/SKILL.md -UseBasicParsing -OutFile "$HOME\.claude\skills\dockerfile-review\SKILL.md"
New-Item -ItemType Directory -Force "$HOME\.agents\skills\dockerfile-review" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/devops/dockerfile-review/SKILL.md -UseBasicParsing -OutFile "$HOME\.agents\skills\dockerfile-review\SKILL.md"
Другой агент: сохраните файл в его папку скиллов или дайте ему ссылку на файл: https://anymodel.org/en/skills/devops/dockerfile-review/SKILL.md
SKILL.md
Dockerfile Review
Write or review a Dockerfile so the image is small, reproducible, cache-friendly and safe to run. Read the whole Dockerfile, .dockerignore, the compose file (if any) and the app's dependency manifests before changing anything.
Workflow
- Identify the runtime (Node, Python, Go, Java ...), how the app starts, which port it listens on and which files it needs at runtime.
- Check each item in the checklist below and note every violation with its line number.
- Apply fixes with the smallest diff that solves each issue. Keep the existing style and stage names.
- Build the image and run a smoke test (see Verification). Report the image size before and after if you can measure it.
Checklist
Base image
- Pin the tag to a specific version, never
latest:node:22.11-slim,python:3.12-slim. For strict reproducibility add the digest (@sha256:...) and tell the user it needs periodic updates. - Prefer slim or distroless variants. Use alpine only when the app has no native dependencies built against glibc (Python wheels and Node native addons often break on musl).
- Use the same base family for build and runtime stages unless a static binary makes that unnecessary.
Multi-stage builds
- Put compilers, dev dependencies and build tools in a
builderstage. Copy only the artifacts into the final stage withCOPY --from=builder. - The final stage must not contain source code, package manager caches,
.gitor test files unless the app needs them to run. - Name stages (
FROM node:22.11-slim AS builder) so the intent is readable.
Layer cache order
- Copy dependency manifests first, install, then copy the rest of the source:
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
- Combine
apt-get updateandapt-get installin oneRUN, use--no-install-recommends, and remove lists in the same layer:rm -rf /var/lib/apt/lists/*. - Order from least to most frequently changing. Put
ARG/ENVthat change per build late.
Reproducible installs
- Node:
npm ci(orpnpm install --frozen-lockfile), nevernpm install. - Python: install from a lock file; use
pip install --no-cache-dir -r requirements.txt, and--require-hasheswhen the requirements file contains hashes. - Go/Rust/Java: build with the lock or vendor files present; do not fetch
latesttools inside the build. - Do not run
curl | shinstallers without pinning a version and verifying a checksum.
Non-root user
- Create a user and switch with
USERbeforeCMD. Numeric ids work better with Kubernetes policies:
RUN groupadd -g 10001 app && useradd -u 10001 -g app -m app
USER 10001:10001
- Make sure the files the app writes to are owned by that user (
COPY --chown=10001:10001). - Do not listen on ports below 1024 as non-root; use 8080 and map it outside.
Secrets and build arguments
- Never put tokens, passwords or keys in
ENV,ARG,COPYorRUNlines.ARGvalues stay visible indocker history. - For private registries or private packages use BuildKit secrets:
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci. - Never copy
.env,*.pemor cloud credential files into an image. If one was already copied, tell the user to rotate that secret.
.dockerignore
- It must exist and exclude at least:
.git,node_modules,.env*,*.log, build output, test artifacts, IDE folders, local virtualenvs. - A missing
.dockerignoremakesCOPY . .leak secrets and bust the cache on every edit.
Runtime hygiene
- Use the exec form for
CMD/ENTRYPOINT(["node", "server.js"]) so signals reach the process; addtinior--initif the app spawns children. - Add a
HEALTHCHECKwhen the image runs outside an orchestrator that has its own probes. Use a tool that exists in the image (do not assumecurlin a slim image). - Set
WORKDIRexplicitly. SetNODE_ENV=production/PYTHONUNBUFFERED=1style variables where relevant. - Use
EXPOSEfor documentation, andLABELfor source and version if the team uses them.
Verification
docker build -t app:review .
docker image ls app:review
docker image inspect --format '{{.Config.User}}' app:review # must not be empty, root or 0
docker history --no-trunc app:review # look for leaked values
If a linter such as hadolint is installed, run it and report its findings. Do not install tools without asking.
Output format
Report back:
- A list of findings, each as
severity | line | problem | fix, sorted by severity (security first). - The changed Dockerfile or a diff.
- Build result, image size, and the user the container runs as.
- Anything you could not verify (for example, no Docker daemon available).
Pitfalls
- Do not "fix" size by deleting files in a later layer; deleted files still exist in earlier layers. Remove them in the same
RUN. - Do not add
--platformor change architectures unless the user asked. - Do not remove a
HEALTHCHECKor a non-root user that the project already has. - Do not push images or tag to a registry without explicit confirmation.
- A change of base image major version can break the app; build and run it before declaring success.
Source: AnyModel skills catalog · License: CC BY 4.0
Подключить через AnyModel API
Скилл работает на той модели, которую использует агент. Подключите Claude Code, Codex или Cursor к AnyModel и запускайте его на Claude, GPT, Gemini и других моделях по одному ключу — оплата за токены, без подписки.
AnyModel