Loading...
Loading...
Production-grade Docker containerization for Python and Node.js applications. This skill should be used when users ask to containerize applications, create Dockerfiles, dockerize projects, or set up Docker Compose. Auto-detects project structure, analyzes .env for secrets, validates security, and generates tested Dockerfiles.
npx skill4agent add panaversity/agentfactory docker# Detect host machine memory
sysctl -n hw.memsize 2>/dev/null | awk '{print $0/1024/1024/1024 " GB"}' || \
grep MemTotal /proc/meminfo | awk '{print $2/1024/1024 " GB"}'
# Detect Docker allocated resources
docker info --format 'Memory: {{.MemTotal}}, CPUs: {{.NCPU}}'
# Detect available disk space
docker system df| Detected Docker Memory | Profile | Build Memory | Container Limits |
|---|---|---|---|
| < 4GB | Constrained | 1GB | 256Mi |
| 4-8GB | Minimal | 2GB | 512Mi |
| 8-12GB | Standard | 4GB | 1Gi |
| > 12GB | Extended | 8GB | 2Gi |
docker_memory * 0.6 / container_countservices:
app:
deploy:
resources:
limits:
memory: 256M
cpus: '0.25'
build:
args:
- BUILDKIT_STEP_LOG_MAX_SIZE=10000000services:
app:
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
reservations:
memory: 256Mservices:
app:
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 512Mdocker build# Check available memory
docker info --format '{{.MemTotal}}' | awk '{if ($1 < 4000000000) print "WARNING: Low memory"}'--memoryoutput: 'standalone':latest| Source | Gather |
|---|---|
| Codebase | Package files, existing Dockerfile, .env patterns |
| Conversation | Dev vs production target, base image preferences |
| Skill References | Framework patterns, multi-stage builds, security |
| User Guidelines | Registry conventions, naming standards |
| Question | When to Ask |
|---|---|
| Target environment | "Building for development or production?" |
| Base image preference | "Standard slim images or enterprise hardened?" |
| Existing Docker files | "Enhance existing Dockerfile or create new?" |
| Registry target | "Local only or pushing to registry?" |
| File Present | Runtime | Package Manager |
|---|---|---|
| Python | pip/uv |
| Node.js | pnpm |
| Node.js | yarn |
| Node.js | npm |
| What | Detect From |
|---|---|
| Python version | |
| Framework | Imports in code ( |
| Package manager | |
| Native deps | Scan requirements: |
| App entrypoint | Find |
| What | Detect From |
|---|---|
| Node version | |
| Framework | |
| Package manager | |
| Output type | Next.js: check |
| Issue | Action |
|---|---|
Next.js missing | Add it to next.config.js |
| No health endpoint found | Create |
| Using uv but no uv.lock | Run |
| pyproject.toml but no build system | Use |
1. SCAN PROJECT
- Detect runtime, framework, version, entrypoint
- Find dependency files, native deps
- Locate existing Docker files (don't blindly overwrite)
↓
2. ANALYZE ENVIRONMENT
- Scan all .env* files
- Classify: SECRET (never bake) / BUILD_ARG / RUNTIME
- Flag security issues
↓
3. FIX CONFIGURATION
- Add Next.js `output: 'standalone'` if missing
- Create health endpoints if missing
- Generate .env.example with safe placeholders
↓
4. GENERATE FILES
- Dockerfile (customized CMD, paths, build deps)
- .dockerignore (excludes .env, secrets)
- compose.yaml (with security defaults)
↓
5. VALIDATE & TEST
- docker build --target dev -t app:dev .
- docker build --target production -t app:prod .
- Test health endpoints
- Verify non-root user
- Report image size
↓
6. DELIVER WITH CONTEXT
- All files with explanations
- Security scan command
- Any warnings about secrets
- Rollback instructions if replacing existing| Choice | When to Use | Tradeoffs |
|---|---|---|
Slim | General production (default) | Works everywhere, no auth |
DHI | SOC2/HIPAA, enterprise | Requires |
Alpine | Smallest size | musl issues with native deps |
deps/base → Install dependencies (cached layer)
↓
builder → Build/compile application
↓
dev → Hot-reload, volume mounts (--target dev)
↓
production → Minimal DHI runtime (--target production)docker build --target dev -t myapp:dev .
docker build --target production -t myapp:prod .| Framework | Development | Production |
|---|---|---|
| FastAPI | | |
| Flask | | |
| Django | | |
RUN \
uv pip install -r requirements.txt@asynccontextmanager
async def lifespan(app: FastAPI):
yield # startup
# shutdown logic here| Framework | Build | Output |
|---|---|---|
| Next.js | | |
| Express | | |
| NestJS | | |
# pnpm
RUN \
pnpm install --frozen-lockfile
# npm
RUN npm ci
# yarn
RUN \
yarn install --frozen-lockfileprocess.on('SIGTERM', () => {
server.close(() => process.exit(0));
});.env.git| File | Purpose |
|---|---|
| Multi-stage, multi-target build |
| Exclude sensitive/unnecessary files |
| Local development stack |
| Framework-specific health checks |
| File | Purpose |
|---|---|
| CRITICAL: Secret detection, .env classification |
| CRITICAL: Validation before delivery |
| File | When to Read |
|---|---|
| FastAPI: uvicorn, lifespan |
| Flask: gunicorn, blueprints |
| Django: gunicorn, middleware |
| Detect psycopg2, cryptography, etc. |
| Next.js: standalone, ISR |
| npm/yarn/pnpm caching |
| File | When to Read |
|---|---|
| If user needs enterprise security (DHI) |
| Complex build patterns |
templates/src.app.main:app# Template says:
CMD ["uvicorn", "app.main:app", ...]
# Agent detects app at src/api/main.py, generates:
CMD ["uvicorn", "src.api.main:app", ...]