Docker containerization

From DNYoussef/context-cascade · View interactive version

Docker containerization is an AI agent skill from the GitHub repository DNYoussef/context-cascade. [assert|neutral] Docker containerization specialist for multi-stage builds, layer caching optimization, security scanning with Trivy, Docker Compose orchestration, BuildKit advanced features, and production-grade Dock [ground:given] [conf:0.95] [state:confirmed]

How to use this skill

Skill file

/============================================================================/

/* DOCKER-CONTAINERIZATION SKILL :: VERILINGUA x VERIX EDITION */

/============================================================================/


name: docker-containerization

version: 1.0.0

description: |

[assert|neutral] Docker containerization specialist for multi-stage builds, layer caching optimization, security scanning with Trivy, Docker Compose orchestration, BuildKit advanced features, and production-grade Dock [ground:given] [conf:0.95] [state:confirmed]

category: Infrastructure

tags:

author: system

cognitive_frame:

primary: aspectual

goal_analysis:

first_order: "Execute docker-containerization workflow"

second_order: "Ensure quality and consistency"

third_order: "Enable systematic Infrastructure processes"


/----------------------------------------------------------------------------/

/* S0 META-IDENTITY */

/----------------------------------------------------------------------------/

[define|neutral] SKILL := {

name: "docker-containerization",

category: "Infrastructure",

version: "1.0.0",

layer: L1

} [ground:given] [conf:1.0] [state:confirmed]

/----------------------------------------------------------------------------/

/* S1 COGNITIVE FRAME */

/----------------------------------------------------------------------------/

[define|neutral] COGNITIVE_FRAME := {

frame: "Aspectual",

source: "Russian",

force: "Complete or ongoing?"

} [ground:cognitive-science] [conf:0.92] [state:confirmed]

Kanitsal Cerceve (Evidential Frame Activation)

Kaynak dogrulama modu etkin.

/----------------------------------------------------------------------------/

/* S2 TRIGGER CONDITIONS */

/----------------------------------------------------------------------------/

[define|neutral] TRIGGER_POSITIVE := {

keywords: ["docker-containerization", "Infrastructure", "workflow"],

context: "user needs docker-containerization capability"

} [ground:given] [conf:1.0] [state:confirmed]

/----------------------------------------------------------------------------/

/* S3 CORE CONTENT */

/----------------------------------------------------------------------------/

Docker Containerization Specialist

Kanitsal Cerceve (Evidential Frame Activation)

Kaynak dogrulama modu etkin.

Expert Docker containerization for production-grade, secure, and optimized container images.

Purpose

Comprehensive Docker expertise including multi-stage builds, layer caching, security scanning, Docker Compose, BuildKit features, and best practices. Ensures containers are small, fast, secure, and production-ready.

When to Use

Prerequisites

Required: Basic Docker commands, understanding of containers vs VMs

Agents: cicd-engineer, security-manager, code-analyzer, backend-dev

Core Workflows

Workflow 1: Multi-Stage Node.js Build

# syntax=docker/dockerfile:1
# 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 package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Stage 3: Production
FROM node:18-alpine AS runner
WORKDIR /app

# Security: Run as non-root
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001

# Copy only necessary files
COPY --from=deps --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
COPY --chown=nodejs:nodejs package.json ./

USER nodejs
EXPOSE 3000
ENV NODE_ENV=production

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1); })"

CMD ["node", "dist/index.js"]

Workflow 2: Python Multi-Stage Build

# syntax=docker/dockerfile:1
FROM python:3.11-slim AS builder

WORKDIR /app

# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt

# Production stage
FROM python:3.11-slim

WORKDIR /app

# Copy Python dependencies from builder
COPY --from=builder /root/.local /root/.local

# Copy application code
COPY . .

# Security: Run as non-root
RUN useradd -m -u 1001 appuser
USER appuser

# Add .local/bin to PATH
ENV PATH=/root/.local/bin:$PATH

EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=3s \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"

CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Workflow 3: Docker Compose Multi-Service App

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.