cli/templates/skills/devops-docker/SKILL.md
Docker containerization best practices. Use when creating Dockerfiles or docker-compose configurations.
npx skillsauth add binhtranquoc/agent-kit-skill devops-dockerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides Docker containerization best practices.
ALWAYS use multi-stage builds to minimize final image size.
# Stage 1: Builder
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: Runner
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 appuser
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER appuser
EXPOSE 3000
CMD ["node", "dist/main.js"]
alpine or slim versions (e.g., node:20-alpine).:latest tag.# Good
FROM node:20.10.0-alpine
# Bad
FROM node:latest
Implement a non-root user for security.
RUN addgroup --system --gid 1001 appgroup
RUN adduser --system --uid 1001 appuser
USER appuser
Order instructions from least to most frequently changed.
# Good order (least changed first)
FROM node:20-alpine
WORKDIR /app
# Dependencies change less often
COPY package*.json ./
RUN npm ci --only=production
# Source changes more often
COPY . .
CMD ["node", "index.js"]
Create .dockerignore to exclude unnecessary files.
# .dockerignore
.git
.gitignore
node_modules
npm-debug.log
Dockerfile
docker-compose*.yml
.env
.env.*
*.md
.vscode
.idea
coverage
dist
.next
# docker-compose.yml
version: '3.8'
services:
api:
container_name: myapp-api
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- DATABASE_URL=${DATABASE_URL}
depends_on:
db:
condition: service_healthy
networks:
- app-network
restart: unless-stopped
db:
container_name: myapp-db
image: postgres:15-alpine
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
postgres-data:
container_name: my-app-api).unless-stopped or always.Never hardcode secrets. Use .env file passing.
# docker-compose.yml
services:
api:
env_file:
- .env
environment:
# Override or add specific vars
- NODE_ENV=production
Create .env.example for documentation:
# .env.example
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb
JWT_SECRET=your-secret-here
:latest)development
Activate Code Reviewer mode for code review and quality assurance. Use when reviewing code for bugs, security issues, or optimization opportunities.
development
Default Implementer mode for writing production code. Use for general coding tasks following project conventions.
development
Activate Debugger mode for systematic bug fixing. Use when debugging errors, investigating issues, or fixing bugs.
testing
Activate Architect mode for system design and architecture decisions. Use when planning features, designing systems, or making architectural choices.