#What it does
The /docker skill analyzes your project and generates production-ready Dockerfiles and Compose configurations. It catches common mistakes like running as root, bloated images, missing health checks, and inefficient layer caching.
#How to use
bash
/docker
/docker optimize
/docker compose#Workflow
- Detect -- Scans the project to identify the runtime, package manager, and framework
- Generate -- Creates a multi-stage Dockerfile optimized for your stack
- Audit -- Reviews existing Dockerfiles for security and size issues
- Compose -- Generates docker-compose.yml with services, volumes, and networks
- Verify -- Runs a test build and reports the final image size
#What it catches
- Security -- Running as root, exposing unnecessary ports, hardcoded secrets in layers
- Size -- Missing multi-stage builds, dev dependencies in production, unneeded system packages
- Caching -- Inefficient layer ordering that invalidates cache on every code change
- Health -- Missing HEALTHCHECK instructions, no graceful shutdown handling
#Example
bash
> /docker optimize
# Analyzing Dockerfile...
! Running as root user (add USER directive)
! COPY . . before dependency install (cache invalidation)
! Image size: 1.2GB (switch to alpine base: ~180MB)
! No HEALTHCHECK defined
# Generating optimized Dockerfile...
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
RUN npm run build
FROM node:20-alpine
RUN addgroup -S app && adduser -S app -G app
USER app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
HEALTHCHECK CMD wget -q --spider http://localhost:3000/health
EXPOSE 3000
CMD ["node", "dist/server.js"]
# Result: 1.2GB -> 178MB (85% reduction)