/devops-skills:container-build-and-releasefrom devops-skills
Builds minimal, multi-stage Dockerfiles with reproducible tagging, multi-arch support, vulnerability scanning, and SBOM generation for CI/CD pipelines.
Ships in devops-skills. 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.
The container image is the deployable unit for most modern services, and
how it's built determines its size, attack surface, build speed, and
whether "the same image" really is the same thing that was tested. Sloppy
Dockerfiles (single-stage, root user, unpinned base images, latest tags)
produce bloated, insecure, and non-reproducible artifacts that undermine
every downstream deployment strategy. This skill covers building small,
reproducible, properly tagged images and publishing them through a
release pipeline with scanning and provenance.
latest usage policy).DOCKER_BUILDKIT=1) — BuildKit enables cache mounts and multi-stage
parallelism used below.docker buildx for multi-architecture builds (bundled with Docker
Desktop and modern Docker Engine installs).debian-slim/alpine, or distroless) — this affects available shell
tooling for debugging vs. attack surface trade-offs.trivy, grype, or the registry's built-in
scanner for vulnerability scanning; syft or docker buildx imagetools
for SBOM generation.Use multi-stage builds to separate build-time dependencies from the runtime image, so compilers, dev headers, and package manager caches never ship in the final image:
# syntax=docker/dockerfile:1.7
FROM node:20-bookworm-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci
COPY . .
RUN npm run build
FROM node:20-bookworm-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --omit=dev
COPY --from=build /app/dist ./dist
RUN useradd --no-create-home --uid 10001 appuser
USER appuser
EXPOSE 3000
ENTRYPOINT ["node", "dist/server.js"]
Pin base images by tag and, for release builds, by digest to make builds reproducible and immune to upstream tag mutation:
FROM node:20.15.1-bookworm-slim@sha256:<digest>
Renovate/Dependabot can automate digest bumps so this doesn't become manual toil.
Order layers from least to most frequently changing so Docker's
layer cache is actually useful: dependency manifests
(package.json/go.mod/requirements.txt) copied and installed
before application source, so a source-only change doesn't
invalidate the dependency install layer.
Run as a non-root user and drop unnecessary capabilities; avoid
--privileged runs and Docker socket mounts in production containers.
Build multi-arch images with buildx when targeting mixed architectures (e.g., amd64 CI runners, arm64 Graviton/Apple Silicon production nodes):
docker buildx create --use --name multiarch-builder
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/example/payments-api:1.4.2 \
--push .
Tag deliberately: give every built image an immutable, traceable tag (commit SHA or semantic version) in addition to any mutable convenience tag:
IMAGE=ghcr.io/example/payments-api
docker buildx build \
-t $IMAGE:1.4.2 \
-t $IMAGE:$(git rev-parse --short HEAD) \
-t $IMAGE:latest \
--push .
Deploy manifests should reference the immutable tag or, ideally, the
resolved digest ($IMAGE@sha256:...) — never deploy latest to a
real environment, since it gives no guarantee of which build is
actually running. See
release-versioning-and-changelog-automation
for how the version number itself should be derived.
Scan the image before publishing it as a release candidate:
trivy image --severity HIGH,CRITICAL --exit-code 1 $IMAGE:1.4.2
Fail the pipeline (or require an explicit waiver) on HIGH/CRITICAL findings rather than publishing and hoping someone checks later.
Generate and attach an SBOM for supply-chain traceability:
syft $IMAGE:1.4.2 -o spdx-json > sbom.spdx.json
docker buildx imagetools create --tag $IMAGE:1.4.2 --annotation index:sbom=sbom.spdx.json ...
Push to the registry and record the resulting digest as a build output so downstream deploy steps deploy an exact digest, not a tag that could be repointed after the fact:
DIGEST=$(docker buildx imagetools inspect $IMAGE:1.4.2 --format '{{json .Manifest.Digest}}')
RUN is still
present in the image history. Use BuildKit secret mounts instead:
RUN --mount=type=secret,id=npmrc npm ci with the secret supplied at
build time (--secret id=npmrc,src=.npmrc), never ARG/ENV for
sensitive values..dockerignore current (exclude .git, node_modules, build
artifacts, local env files) to shrink build context and avoid
accidentally copying secrets/local config into the image.edge, nightly) — never let
latest silently become "whatever was last pushed" for anything
customers or production depend on.Symptom: Image is several hundred MB larger than expected for a simple service. Fix: Check for a single-stage build carrying build tools/dev dependencies into runtime, or a base image that isn't a slim/minimal variant; switch to multi-stage and copy only build outputs into the runtime stage.
Symptom: A secret used during build (private package registry
token) is discoverable via docker history or by extracting layers,
even though it's not in the final ENV.
Fix: Any value passed via ARG/ENV or written to a file and later
deleted in a subsequent RUN still persists in that layer's history.
Use BuildKit --mount=type=secret so the secret is never written to a
committed layer at all.
Symptom: "It worked in staging but broke in prod" despite deploying
"the same image."
Fix: Check whether prod is actually pulling latest (or a tag that
moved between staging and prod deploy) rather than the exact digest
that was tested; pin deploys to an immutable tag or digest.
Symptom: Multi-arch build succeeds on CI (amd64) but the arm64 variant crashes at runtime on Graviton/Apple Silicon nodes. Fix: The image likely wasn't actually tested on the second architecture — run integration tests against both platforms (via QEMU emulation or native arm64 runners) before publishing a multi-arch manifest as a release.
Symptom: Vulnerability scan flags dozens of CVEs in the base OS layer that have nothing to do with the application. Fix: Confirm the base image is current (rebuild against the latest patch tag/digest of the same minor version) before triaging individual CVEs — many disappear simply by rebuilding against an up-to-date base.
Scenario: Build, scan, and publish a release image for payments-api
version 1.4.2 from a GitHub Actions pipeline, targeting both amd64 and
arm64, with a failing gate on critical vulnerabilities.
name: release-image
on:
push:
tags: ["v*.*.*"]
jobs:
build-scan-push:
runs-on: ubuntu-latest
permissions: { contents: read, packages: write }
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Derive version
id: ver
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Build (local, for scan)
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: local/payments-api:scan
- name: Scan
run: |
trivy image --severity HIGH,CRITICAL --exit-code 1 local/payments-api:scan
- name: Build and push multi-arch
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/example/payments-api:${{ steps.ver.outputs.version }}
ghcr.io/example/payments-api:${{ github.sha }}
A tag push of v1.4.2 produces
ghcr.io/example/payments-api:1.4.2 (and a SHA-tagged twin for exact
traceability), only after the scan gate passes — the deploy pipeline
(see blue-green-canary-deployments)
then references that immutable tag, never latest.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
docker, dockerfile, container-image, image-scanning, multi-arch, image-tagging
16 skills in this plugin
/artifact-and-dependency-managementManages build artifacts and third-party dependencies through a private registry/proxy with lockfiles, version pinning, retention policies, and automated update workflows. Use when the user asks to "set up an artifact repository," "configure a package registry proxy/mirror," "pin/lock dependency versions," "clean up old artifacts," "handle a dependency update / Dependabot-Renovate PR," or "avoid a left-pad-style supply-chain incident."
/blue-green-canary-deploymentsDesigns and executes progressive delivery strategies — blue-green cutover, canary rollout, and traffic-shifted releases — with automated health checks and rollback triggers, typically on Kubernetes. Use when the user asks to "reduce deployment risk," "set up canary/blue-green deployments," "do a zero-downtime release," "gradually shift traffic to a new version," or "automatically roll back a bad deploy."
/ci-access-and-credential-lifecycle-managementManages the lifecycle of one-off/temporary repo and environment access grants and CI service-account credentials — granting time-boxed access for a specific task, revoking it reliably when the task ends, and rotating CI service-account tokens/keys before they expire or become stale. Use when the user asks to "give a contractor temporary repo access," "grant one-off access to the production environment," "rotate our CI service account token/API key," "find and revoke stale CI credentials," or "our CI token is about to expire, what do we do."
/ci-cd-pipeline-designDesigns and troubleshoots CI/CD pipelines (GitHub Actions, GitLab CI, or equivalent) including stage layout, caching, parallelization, quality gates, and secrets handling. Use when the user asks to "set up a CI/CD pipeline," "add a build/test/deploy workflow," "fix a failing pipeline stage," "speed up CI," "add branch protection / required checks," or "design a deployment pipeline" for an application or infrastructure repo.
/devops-delivery-metrics-and-dora-analysisMeasures and interprets the DORA four keys — deployment frequency, lead time for changes, mean time to restore (MTTR), and change failure rate — including how to compute each one correctly, common measurement pitfalls (vanity metrics, gaming the numbers, misclassifying a rollback), and how to use the results to drive process improvement rather than individual blame. Use when the user asks to "set up DORA metrics," "measure our deployment frequency/lead time," "what's our change failure rate," "are we an elite/high/medium/low performer," or "use delivery metrics to improve, not to blame the team."
/emergency-hotfix-deployment-procedureDefines the out-of-cadence process for shipping a production hotfix outside the normal release train — which checks are genuinely safe to bypass versus never, the minimum required verification before an emergency deploy, required sign-off, and the rollback plan that must exist before the hotfix goes out. Use when the user asks to "ship an emergency hotfix," "deploy outside the normal release process," "bypass the release train for a critical fix," "what's the minimum we can skip for a production emergency," or "we need to patch prod right now."
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin devops-skillsOther plugins' skills for the same job