Docker Setup
- Detect project type:
cat package.json 2>/dev/null | grep '"main"\|"start"\|"scripts"' -A 5
ls -la | grep -E "Dockerfile|docker-compose|\.dockerignore"
- If Dockerfile exists, review it for:
- Multi-stage build (build stage vs runtime stage)
- Layer caching order (dependencies before source)
- Running as non-root user
.dockerignore completeness
- Image size optimization
- If no Dockerfile, generate one following best practices:
# Multi-stage: build → runtime
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
FROM node:20-alpine AS runtime
RUN addgroup -S app && adduser -S app -G app
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY . .
USER app
EXPOSE 3000
CMD ["node", "dist/index.js"]
- Also create/update
.dockerignore:
node_modules
dist
.env*
.git
coverage
*.test.*
- Show
docker build and docker run commands to test.
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.