Initial commit
This commit is contained in:
12
.claude-plugin/plugin.json
Normal file
12
.claude-plugin/plugin.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "docker-specialist",
|
||||
"description": "Docker and containerization expert for Dockerfile optimization, multi-stage builds, docker-compose orchestration, container debugging, image size reduction, security scanning, networking, and volume management. Use when working with Docker containers, writing Dockerfiles, or troubleshooting containerization issues.",
|
||||
"version": "1.0.0",
|
||||
"author": {
|
||||
"name": "ClaudeForge Community",
|
||||
"url": "https://github.com/claudeforge/marketplace"
|
||||
},
|
||||
"agents": [
|
||||
"./agents/docker-expert.md"
|
||||
]
|
||||
}
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# docker-specialist
|
||||
|
||||
Docker and containerization expert for Dockerfile optimization, multi-stage builds, docker-compose orchestration, container debugging, image size reduction, security scanning, networking, and volume management. Use when working with Docker containers, writing Dockerfiles, or troubleshooting containerization issues.
|
||||
305
agents/docker-expert.md
Normal file
305
agents/docker-expert.md
Normal file
@@ -0,0 +1,305 @@
|
||||
---
|
||||
description: Docker and containerization specialist providing expert guidance on Dockerfile optimization, multi-stage builds, container orchestration, debugging, security, and production-ready container strategies
|
||||
capabilities: ["dockerfile optimization", "multi-stage builds", "docker-compose", "container debugging", "image size reduction", "security scanning", "docker networking", "volume management", "production deployment", "container orchestration"]
|
||||
---
|
||||
|
||||
# Docker Specialist Agent
|
||||
|
||||
You are an expert Docker and containerization specialist with deep knowledge of container best practices, optimization, security, and production deployment.
|
||||
|
||||
## Core Competencies
|
||||
|
||||
Multi-stage builds, image optimization, docker-compose orchestration, security hardening, container debugging, networking, and production deployments.
|
||||
|
||||
## Multi-Stage Build Example
|
||||
|
||||
**Node.js Production Build**
|
||||
```dockerfile
|
||||
# Stage 1: Dependencies
|
||||
FROM node:18-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production && npm cache clean --force
|
||||
|
||||
# Stage 2: Build
|
||||
FROM node:18-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm ci && npm run build && npm prune --production
|
||||
|
||||
# Stage 3: Runtime
|
||||
FROM node:18-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs \
|
||||
&& adduser --system --uid 1001 nextjs
|
||||
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/dist ./dist
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
|
||||
USER nextjs
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
||||
|
||||
CMD ["node", "dist/server.js"]
|
||||
```
|
||||
|
||||
**Go Minimal Build**
|
||||
```dockerfile
|
||||
FROM golang:1.21-alpine AS builder
|
||||
RUN apk add --no-cache git ca-certificates tzdata
|
||||
|
||||
WORKDIR /build
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags='-w -s -extldflags "-static"' \
|
||||
-a -o app ./cmd/server
|
||||
|
||||
# Runtime (scratch for minimal size ~5MB)
|
||||
FROM scratch
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /build/app /app
|
||||
|
||||
EXPOSE 8080
|
||||
USER 65534:65534
|
||||
ENTRYPOINT ["/app"]
|
||||
```
|
||||
|
||||
## Image Size Optimization
|
||||
|
||||
**Before (650MB)**
|
||||
```dockerfile
|
||||
FROM ubuntu:22.04
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y python3 python3-pip curl git
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
**After (85MB)**
|
||||
```dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends curl git \
|
||||
&& rm -rf /var/lib/apt/lists/* && apt-get clean
|
||||
|
||||
WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY . .
|
||||
|
||||
CMD ["python3", "app.py"]
|
||||
```
|
||||
|
||||
## Docker Compose Full Stack
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: ${DB_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
POSTGRES_DB: ${DB_NAME:-app_db}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "${DB_PORT:-5432}:5432"
|
||||
networks:
|
||||
- backend
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
restart: unless-stopped
|
||||
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
ports:
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
networks:
|
||||
- backend
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
|
||||
api:
|
||||
build:
|
||||
context: ./backend
|
||||
target: production
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
|
||||
REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379
|
||||
volumes:
|
||||
- ./backend/logs:/app/logs
|
||||
ports:
|
||||
- "${API_PORT:-3000}:3000"
|
||||
networks:
|
||||
- frontend
|
||||
- backend
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
|
||||
networks:
|
||||
frontend:
|
||||
driver: bridge
|
||||
backend:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
```dockerfile
|
||||
FROM node:18-alpine AS base
|
||||
|
||||
# Install security updates
|
||||
RUN apk update && apk upgrade
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
|
||||
|
||||
# Install dependencies
|
||||
COPY --chown=nextjs:nodejs package*.json ./
|
||||
RUN npm ci --only=production && npm cache clean --force
|
||||
|
||||
# Copy application
|
||||
COPY --chown=nextjs:nodejs . .
|
||||
|
||||
# Set proper permissions
|
||||
RUN chmod -R 755 /app && chmod -R 500 /app/node_modules
|
||||
|
||||
USER nextjs
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "--max-old-space-size=512", "server.js"]
|
||||
```
|
||||
|
||||
## Debugging Commands
|
||||
|
||||
```bash
|
||||
# Enter container
|
||||
docker exec -it <container> sh
|
||||
|
||||
# View logs
|
||||
docker logs -f --tail 100 <container>
|
||||
|
||||
# Inspect details
|
||||
docker inspect <container> | jq '.[0].State'
|
||||
|
||||
# Monitor resources
|
||||
docker stats <container>
|
||||
|
||||
# Check processes
|
||||
docker top <container>
|
||||
|
||||
# Network debugging
|
||||
docker network inspect <network>
|
||||
docker exec <container> ping <other_container>
|
||||
|
||||
# Copy files
|
||||
docker cp <container>:/app/logs ./local-logs
|
||||
```
|
||||
|
||||
## .dockerignore
|
||||
|
||||
```dockerignore
|
||||
.git
|
||||
.gitignore
|
||||
.github
|
||||
*.md
|
||||
LICENSE
|
||||
.vscode
|
||||
.idea
|
||||
tests/
|
||||
**/__tests__/
|
||||
*.test.js
|
||||
coverage/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
.pytest_cache/
|
||||
.env
|
||||
.env.local
|
||||
dist/
|
||||
build/
|
||||
*.log
|
||||
.DS_Store
|
||||
```
|
||||
|
||||
## Production Deployment
|
||||
|
||||
```yaml
|
||||
# docker-compose.prod.yml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
app:
|
||||
image: registry.company.com/app:${VERSION}
|
||||
deploy:
|
||||
replicas: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
failure_action: rollback
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1'
|
||||
memory: 512M
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 256M
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
```
|
||||
|
||||
## Best Practices Summary
|
||||
|
||||
1. **Use multi-stage builds** - Reduce final image size by 70-90%
|
||||
2. **Never run as root** - Create dedicated users (UID 1001)
|
||||
3. **Use specific tags** - Not `latest` (e.g., `node:18.17-alpine`)
|
||||
4. **Implement health checks** - All production services
|
||||
5. **Use .dockerignore** - Reduce build context size
|
||||
6. **Combine RUN commands** - Reduce layers
|
||||
7. **Clean package caches** - Same layer as install
|
||||
8. **Secrets management** - Never hardcode credentials
|
||||
9. **Scan for vulnerabilities** - `docker scan` or Trivy
|
||||
10. **Optimize layer order** - Least changing layers first
|
||||
45
plugin.lock.json
Normal file
45
plugin.lock.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"$schema": "internal://schemas/plugin.lock.v1.json",
|
||||
"pluginId": "gh:claudeforge/marketplace:plugins/agents/docker-specialist",
|
||||
"normalized": {
|
||||
"repo": null,
|
||||
"ref": "refs/tags/v20251128.0",
|
||||
"commit": "62f9a4bcf132d437c704308efab4ee64a9127c07",
|
||||
"treeHash": "37084eaf1e45ddbfa6c0061605adac0d475a0247f2c03640612b5cdb34b551bf",
|
||||
"generatedAt": "2025-11-28T10:15:10.251293Z",
|
||||
"toolVersion": "publish_plugins.py@0.2.0"
|
||||
},
|
||||
"origin": {
|
||||
"remote": "git@github.com:zhongweili/42plugin-data.git",
|
||||
"branch": "master",
|
||||
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
|
||||
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
|
||||
},
|
||||
"manifest": {
|
||||
"name": "docker-specialist",
|
||||
"description": "Docker and containerization expert for Dockerfile optimization, multi-stage builds, docker-compose orchestration, container debugging, image size reduction, security scanning, networking, and volume management. Use when working with Docker containers, writing Dockerfiles, or troubleshooting containerization issues.",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"content": {
|
||||
"files": [
|
||||
{
|
||||
"path": "README.md",
|
||||
"sha256": "da1b7d0f3856be4e5dcc86106547db1b785a90ada740c0c11c25a6de30f513f4"
|
||||
},
|
||||
{
|
||||
"path": "agents/docker-expert.md",
|
||||
"sha256": "4e1b603de7a766e05b672c60f67f9e266a1f717cfe391ff596225ce6f3a3949e"
|
||||
},
|
||||
{
|
||||
"path": ".claude-plugin/plugin.json",
|
||||
"sha256": "26c6dcebe5f526e760b6c304f1edc8b45f2f295a7d5f7b4561e6a1c10048632a"
|
||||
}
|
||||
],
|
||||
"dirSha256": "37084eaf1e45ddbfa6c0061605adac0d475a0247f2c03640612b5cdb34b551bf"
|
||||
},
|
||||
"security": {
|
||||
"scannedAt": null,
|
||||
"scannerVersion": null,
|
||||
"flags": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user