Dockerfile patterns

From uw-ssec/rse-plugins · View interactive version

Dockerfile patterns is an AI agent skill from the GitHub repository uw-ssec/rse-plugins. Use when the user asks about writing, optimizing, or debugging Dockerfiles, containerizing applications, or building Docker images with docker build. Covers multi-stage builds, layer caching, base image selection, security hardening, and language-specific patterns for Python, Node, Rust, R, Go, Juli

How to use this skill

Skill file

Dockerfile Patterns

Primary Actions

Quick Build Pattern

FROM python:3.11 AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --prefix=/install -r requirements.txt
COPY . .

FROM python:3.11-slim
WORKDIR /app
COPY --from=builder /install /usr/local
COPY --from=builder /app /app
RUN useradd -u 1001 -m appuser
USER 1001
ENTRYPOINT ["python", "-m", "myapp"]

Validation Workflow

  1. Build the image (docker build).
  2. Run startup check (docker run --rm <image> --help or equivalent).
  3. For services, run a smoke check with expected command/port.
  4. Run vulnerability scan before release (trivy image or docker scout cves).
  5. If validation fails, revise Dockerfile and rebuild.

Language Templates

Deep References

references/multi-stage-builds.md

references/layer-caching.md

references/base-image-selection.md

references/build-validation-and-ops.md

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.