Purpose
Build production-grade container images and Kubernetes configurations optimized for security, performance, and reliability.
When to Use
Use this skill when the task involves:
- Writing or optimizing Dockerfiles
- Creating Kubernetes Deployments, Services, or ConfigMaps
- Setting up health checks, resource limits, or autoscaling
- Configuring Ingress with Istio, Emissary, or nginx
- Building Helm charts for deployable applications
- Troubleshooting container or pod issues
Constraints
- Dockerfiles must use multi-stage builds to minimize image size
- Always run as non-root user in production images
- Pin image versions with SHA digests for reproducibility
- Kubernetes manifests must define resource requests AND limits
- Include liveness, readiness, and startup probes
- Use semantic versioning for container image tags
- Apply Pod Disruption Budgets for high-availability workloads
Execution Steps
- Analyze application — Identify runtime requirements, dependencies, ports
- Design Dockerfile — Multi-stage build with optimized layer ordering
- Add security hardening — Non-root user, minimal base image, no secrets in image
- Create K8s manifests — Deployment, Service, ConfigMap, Secrets references
- Configure reliability — Probes, resource limits, PDBs, HPA
- Set up networking — Ingress, network policies, service mesh integration
- Verify locally — Test with docker build and kubectl dry-run
Examples
Input
Create an optimized Dockerfile for a Next.js application
Output
# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile
# Stage 2: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN corepack enable pnpm && pnpm build
# Stage 3: Production
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Security: non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
CMD ["node", "server.js"]
Kubernetes Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: nextjs-app
spec:
replicas: 3
selector:
matchLabels:
app: nextjs-app
template:
spec:
containers:
- name: app
image: myregistry/nextjs-app:v1.0.0@sha256:abc123...
ports:
- containerPort: 3000
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 10
readinessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 5
Related Skills
terraform-aws-builder — Provision EKS clusters
telemetry-opentelemetry-integrator — Add observability to containers
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: docker-k8s-optimizer3description: Optimize Dockerfiles with multi-stage builds, layer caching, and security hardening; create Kubernetes manifests with resource limits, probes, HPA, PDB, network policies, and Helm charts Use when this capability is needed.4---56# Purpose78Build production-grade container images and Kubernetes configurations optimized for security, performance, and reliability.910## When to Use1112Use this skill when the task involves:1314- Writing or optimizing Dockerfiles15- Creating Kubernetes Deployments, Services, or ConfigMaps16- Setting up health checks, resource limits, or autoscaling17- Configuring Ingress with Istio, Emissary, or nginx18- Building Helm charts for deployable applications19- Troubleshooting container or pod issues2021## Constraints2223- Dockerfiles must use **multi-stage builds** to minimize image size24- Always run as **non-root user** in production images25- Pin image versions with **SHA digests** for reproducibility26- Kubernetes manifests must define **resource requests AND limits**27- Include **liveness, readiness, and startup probes**28- Use **semantic versioning** for container image tags29- Apply **Pod Disruption Budgets** for high-availability workloads3031## Execution Steps32331. **Analyze application** — Identify runtime requirements, dependencies, ports342. **Design Dockerfile** — Multi-stage build with optimized layer ordering353. **Add security hardening** — Non-root user, minimal base image, no secrets in image364. **Create K8s manifests** — Deployment, Service, ConfigMap, Secrets references375. **Configure reliability** — Probes, resource limits, PDBs, HPA386. **Set up networking** — Ingress, network policies, service mesh integration397. **Verify locally** — Test with docker build and kubectl dry-run4041## Examples4243### Input4445> Create an optimized Dockerfile for a Next.js application4647### Output4849```dockerfile50# Stage 1: Dependencies51FROM node:20-alpine AS deps52WORKDIR /app53COPY package.json pnpm-lock.yaml ./54RUN corepack enable pnpm && pnpm install --frozen-lockfile5556# Stage 2: Build57FROM node:20-alpine AS builder58WORKDIR /app59COPY --from=deps /app/node_modules ./node_modules60COPY . .61ENV NEXT_TELEMETRY_DISABLED=162RUN corepack enable pnpm && pnpm build6364# Stage 3: Production65FROM node:20-alpine AS runner66WORKDIR /app67ENV NODE_ENV=production68ENV NEXT_TELEMETRY_DISABLED=16970# Security: non-root user71RUN addgroup --system --gid 1001 nodejs && \72 adduser --system --uid 1001 nextjs7374COPY --from=builder /app/public ./public75COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./76COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static7778USER nextjs79EXPOSE 300080ENV PORT=300081CMD ["node", "server.js"]82```8384### Kubernetes Deployment8586```yaml87apiVersion: apps/v188kind: Deployment89metadata:90 name: nextjs-app91spec:92 replicas: 393 selector:94 matchLabels:95 app: nextjs-app96 template:97 spec:98 containers:99 - name: app100 image: myregistry/nextjs-app:v1.0.0@sha256:abc123...101 ports:102 - containerPort: 3000103 resources:104 requests:105 cpu: 100m106 memory: 128Mi107 limits:108 cpu: 500m109 memory: 512Mi110 livenessProbe:111 httpGet:112 path: /api/health113 port: 3000114 initialDelaySeconds: 10115 readinessProbe:116 httpGet:117 path: /api/health118 port: 3000119 initialDelaySeconds: 5120```121122## Related Skills123124- `terraform-aws-builder` — Provision EKS clusters125- `telemetry-opentelemetry-integrator` — Add observability to containers126127---128> Converted and distributed by [TomeVault](https://tomevault.io/claim/phatpham9) — claim your Tome and manage your conversions.129<!-- tomevault:4.0:skill_md:2026-04-11 -->