Manages multi-stage Docker builds and Kubernetes resource quotas for efficient container orchestration of 18 agent types
This skill provides advanced container orchestration techniques optimized for managing 18 distinct agent types in a high-density Kubernetes environment, focusing on efficient resource utilization and preventing resource contention.
Run this skill when:
# Stage 1: Builder stage with full Node.js
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
# Stage 2: Runtime with minimal Alpine
FROM alpine:3.18
# Install only runtime dependencies
RUN apk add --no-cache \
nodejs \
npm \
&& addgroup -g 1001 -S nodejs \
&& adduser -S nextjs -u 1001
WORKDIR /app
COPY --from=builder --chown=nextjs:nodejs /app/package*.json ./
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/dist ./dist
USER nextjs
EXPOSE 3000
CMD ["node", "dist/server.js"]
# Stage 1: Build application
FROM golang:1.21-alpine AS builder
WORKDIR /go/src/app
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# Stage 2: Distroless runtime
FROM gcr.io/distroless/static-debian11
COPY --from=builder /go/src/app/main /
EXPOSE 8080
CMD ["/main"]
# Base image for all ML agents
FROM python:3.11-slim AS base-ml
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install common ML dependencies
COPY requirements-base.txt .
RUN pip install --no-cache-dir -r requirements-base.txt
# Specific agent builds
FROM base-ml AS sentiment-agent
COPY sentiment-requirements.txt .
RUN pip install --no-cache-dir -r sentiment-requirements.txt
COPY sentiment-agent.py .
CMD ["python", "sentiment-agent.py"]
FROM base-ml AS classification-agent
COPY classification-requirements.txt .
RUN pip install --no-cache-dir -r classification-requirements.txt
COPY classification-agent.py .
CMD ["python", "classification-agent.py"]
# Use .dockerignore to minimize context
# .dockerignore
node_modules
.git
*.log
coverage/
.nyc_output/
dist/
.next/
out/
# Multi-stage for efficient layer caching
FROM node:18-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --only=production && npm cache clean --force
FROM node:18-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
FROM node:18-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
EXPOSE 3000
CMD ["npm", "start"]
apiVersion: v1