/devops-oncall:multi-stage-dockerfilefrom devops-oncall
Designs optimized multi-stage Dockerfiles with builder, dependency, test, and runtime stages to minimize image size, improve layer caching, and secure runtime containers.
Ships in devops-oncall. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Design a Dockerfile that separates build-time work from runtime execution, minimizes the final image, preserves reproducibility, and avoids leaking tools or secrets into production layers.
| Stage | Purpose | Common contents | Must not contain |
|---|---|---|---|
deps | Restore dependency manifests before source changes. | package-lock.json, requirements.txt, .csproj, lockfiles. | Full source when not needed for restore. |
builder | Compile, bundle, transpile, or publish artifacts. | SDK image, compiler, build tools, source code. | Runtime-only secrets. |
test | Optional validation when tests should run during image build. | Test runner and test dependencies. | Production entrypoint assumptions. |
runtime | Run the app with the minimum required files. | Published artifacts, runtime libraries, config defaults, non-root user. | Compilers, package caches, source not needed at runtime. |
Use meaningful names with AS, for example FROM node:18 AS builder, and order stages as dependencies → build → test → runtime.
| Decision | Rule |
|---|---|
| Image source | Prefer official base images or trusted distroless runtime images. |
| Tags | Pin exact version tags such as python:3.11-slim; do not use floating tags like latest or bare python. |
| Alpine | Use Alpine only when native dependencies, libc assumptions, and debugging needs are compatible. |
| Distroless | Use distroless when the app does not need a shell or package manager at runtime. |
| Runtime dependencies | Install only libraries required to launch the application. |
| Pattern | Why it matters |
|---|---|
| Copy dependency manifests before source files. | Dependency restore layers remain cached when application code changes. |
Put frequently changing COPY . . late. | Avoid invalidating expensive install/build layers. |
Add .dockerignore. | Exclude .git, local build output, caches, secrets, test reports, and dependency directories that should be restored inside the image. |
Combine related RUN commands with &&. | Reduce layer count and allow cleanup in the same layer. |
Use COPY --chown=<user>:<group>. | Set ownership without an extra RUN chown layer. |
| Use build arguments intentionally. | Keep environment-specific values configurable without baking secrets into layers. |
USER; create only the required UID/GID and directories.ARG or ENV; use BuildKit secrets when secrets are unavoidable during build.NODE_ENV=production when they are correct for the framework.HEALTHCHECK that validates the application process or HTTP endpoint without requiring privileged tools.## Multi-stage Dockerfile result - <app>
**Status:** created | updated | recommendation only | blocked
**Runtime image:** `<image:tag>`
### Dockerfile
```dockerfile
FROM <base>:<version> AS deps
<dependency restore commands>
FROM <base>:<version> AS builder
<build commands>
FROM <runtime>:<version> AS runtime
<copy artifacts, configure USER, EXPOSE, HEALTHCHECK, ENTRYPOINT/CMD>
```
### Companion files
```dockerignore
<entries such as .git, build output, caches, secrets, dependency directories>
```
### Validation
- Build command: `docker build -t <image> .` - <pass/fail/not run>
- Runtime check: `<docker run or healthcheck evidence>` - <pass/fail/not run>
.dockerignore excludes local caches, VCS data, secrets, and generated output.USER unless a documented platform constraint prevents it.ARG, ENV, image layers, or copied files.NODE_ENV=production or equivalent runtime optimization is used only when appropriate.HEALTHCHECK is included or a reason for omission is documented.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
2 skills in this plugin
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin devops-oncallOther plugins' skills for the same job