No slash command · from container-plugin
Optimizes Node.js Docker images using Alpine, multi-stage builds, BuildKit cache mounts, and production-only dependencies. Reduces image size from ~900MB to ~100MB.
Ships in container-plugin. 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.
Read when SKILL.md points to them.
Expert knowledge for building optimized Node.js container images using Alpine variants, multi-stage builds, and Node.js-specific dependency management patterns.
| Use this skill when... | Use container-development instead when... |
|---|---|
| Building Node.js-specific Dockerfiles | General multi-stage build patterns |
| Optimizing Node.js image sizes | Language-agnostic container security |
| Handling npm/yarn/pnpm in containers | Docker Compose configuration |
| Dealing with native module builds | Non-Node.js container optimization |
Node.js Container Challenges:
Key Capabilities:
The recommended pattern achieves ~100-150MB images:
# Dependencies stage - production only
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
# Build stage - includes devDependencies
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Runtime stage - minimal
FROM node:20-alpine
WORKDIR /app
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -u 1001 -S nodejs -G nodejs
# Copy dependencies and built app
COPY --from=deps --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --from=build --chown=nodejs:nodejs /app/dist ./dist
COPY --chown=nodejs:nodejs package.json ./
USER nodejs
EXPOSE 3000
HEALTHCHECK --interval=30s CMD node healthcheck.js || exit 1
CMD ["node", "dist/server.js"]
# syntax=docker/dockerfile:1
FROM node:20-alpine AS build
WORKDIR /app
# Cache mount for npm cache
RUN --mount=type=cache,target=/root/.npm \
--mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=build /app/dist ./dist
USER node
CMD ["node", "dist/server.js"]
Build performance:
COPY package*.json ./
RUN npm ci --only=production
RUN npm cache clean --force
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production
RUN yarn cache clean
RUN npm install -g pnpm
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod
# pnpm creates smaller node_modules with hard links (20-30% smaller)
Bun works for the dependency and build stages of a Next.js image, but the
runtime stage that serves .next/standalone must be Node.js. The standalone
output targets Node, and Bun does not resolve the React Server Components SSR
modules it loads (react-dom/server.edge, react-dom/server-rendering-stub,
react-server-dom-webpack/client.edge), so it fails at runtime with
"Could not resolve" errors.
FROM oven/bun:1-debian AS deps # install
FROM oven/bun:1-debian AS builder # next build
FROM gcr.io/distroless/nodejs22-debian12 AS runner
CMD ["server.js"]
child_process to CLI toolsA distroless Node image contains Node and nothing else: no /bin/sh, gzip,
pg_dump, or psql. Application code that shells out through
node:child_process (exec, execSync, spawn of a CLI) works in local dev
and fails only in production, with spawn /bin/sh ENOENT. Use Node built-ins
or a library instead:
| Shell tool | In-process replacement |
|---|---|
gzip / gunzip | node:zlib (gzipSync, createGzip, gunzipSync) |
cat, cp, file writes | node:fs |
pg_dump / psql | export/import through the app's database client or ORM |
The same constraint means ops scripts cannot be kubectl exec'd into the
running app pod. Ship them in a separate image and run them as a Job. To stop
the mistake before review, ban the import with a lint rule (for example Biome
noRestrictedImports on node:child_process for server source).
| Metric | Full Node (900MB) | Alpine (350MB) | Multi-Stage (100MB) | Improvement |
|---|---|---|---|---|
| Image Size | 900MB | 350MB | 100MB | 89% reduction |
| Pull Time | 3m 20s | 1m 10s | 25s | 87% faster |
| Build Time | 4m 30s | 3m 15s | 2m 30s | 44% faster |
| Rebuild (cached) | 2m 10s | 1m 30s | 15s | 88% faster |
| Memory Usage | 512MB | 256MB | 180MB | 65% reduction |
| Image Type | Vulnerabilities | Size | Risk |
|---|---|---|---|
| node:20 (Debian) | 45-60 CVEs | 900MB | High |
| node:20-alpine | 8-12 CVEs | 350MB | Medium |
| Multi-stage Alpine | 4-8 CVEs | 100MB | Low |
| Distroless Node | 2-4 CVEs | 120MB | Very Low |
| Context | Command | Purpose |
|---|---|---|
| Fast rebuild | DOCKER_BUILDKIT=1 docker build --target build . | Build only build stage |
| Size check | docker images app --format "table {{.Repository}}\t{{.Size}}" | Compare sizes |
| Layer analysis | docker history app:latest --human --no-trunc | head -20 | Find large layers |
| Dependency audit | docker run --rm app npm audit --production | Check vulnerabilities |
| Cache clear | docker builder prune --filter type=exec.cachemount | Clear BuildKit cache |
| Test locally | docker run --rm -p 3000:3000 app | Quick local test |
npm ci not npm install (reproducible builds)For detailed examples, advanced patterns, and best practices, see REFERENCE.md.
container-development - General container patterns, multi-stage builds, securitygo-containers - Go-specific container optimizationspython-containers - Python-specific container optimizationsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
docker-optimization, alpine, multi-stage-build, buildkit, node-docker
9 skills in this plugin
/container-developmentDockerfiles and containers — multi-stage builds, non-root, slim images, CVE/Trivy fixes in a base image. Use when writing or patching a Dockerfile, docker-compose, or a container scan finding./deploy-handoffGenerate deployment handoff docs — tech stack, access URLs, config, monitoring, dev checklist. Use when handing off a service, documenting deployments, or creating client-facing summaries./deploy-releaseCreate and publish releases via release-please or manual GitHub releases. Use when cutting a release, tagging a version, or setting up release-please config./go-containersGo container optimization — scratch/distroless images, static binaries, CGO, ldflags, trimpath (846MB to 2.5MB). Use when working with Go containers or optimizing Go image sizes./python-containersPython container optimization — slim images (not Alpine), virtualenv, multi-stage, pip/poetry/uv, musl gotchas (1GB to ~120MB). Use when working with Python containers or optimizing image sizes./skaffold-filesyncSkaffold file sync — copy changed files to containers without rebuilding. Use when optimizing the dev loop, configuring sync rules, or the user mentions hot reload or fast iteration.npx claudepluginhub laurigates/claude-plugins --plugin container-pluginOther plugins' skills for the same job