Set up complete Docker-based virtualized deployment infrastructure with docker-compose, multi-environment support (local build vs production images), registry management with prefix switching, fine-grained versioning, and network-aware build/push scripts. Use this skill when users ask for Docker deployment setup, containerization, docker-compose configuration, multi-environment deployments, registry management, or building production-ready container infrastructure. Essential for projects requiring local development with Docker and production deployment to private registries.
This skill creates a complete, production-ready Docker deployment infrastructure with support for multiple environments, registry management, and network-aware operations.
docker-compose.yml brings up the entire stack including all dependencieslatest tags)deploy/
├── docker-compose.yml # Main orchestration file
├── docker-compose.override.yml # Local development overrides (optional)
├── .env.template # Environment variable template
├── .env # Local environment config (gitignored)
├── scripts/
│ ├── build.sh # Build images locally
│ ├── push.sh # Push to registry
│ └── build-and-push.sh # Complete build + push workflow
├── services/
│ ├── service-a/
│ │ └── Dockerfile
│ └── service-b/
│ └── Dockerfile
└── README.md # Usage instructions
First, understand the project:
Create .env.template with all configurable values:
# Registry Configuration
REGISTRY_PREFIX=localhost:5000 # Change for production: registry.example.com
# Application Versions
APP_VERSION=1.0.0
# Service Configuration
SERVICE_A_PORT=8080
SERVICE_B_PORT=8081
# Database Configuration
DB_VERSION=15.4
DB_NAME=myapp
DB_USER=myuser
DB_PASSWORD=changeme
DB_PORT=5432
# Cache Configuration
REDIS_VERSION=7.2.3
REDIS_PORT=6379
# Environment
ENV=local # local, staging, production
Key rules:
15.4 not latest or 15For each application service, create optimized Dockerfiles:
Multi-stage build example:
# Stage 1: Build
FROM node:20.11.0-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
# Stage 2: Production
FROM node:20.11.0-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package.json ./
EXPOSE 3000
USER node
CMD ["node", "dist/main.js"]
Requirements:
node:20.11.0-alpine, not node:alpine)Create the main docker-compose.yml using registry prefix pattern: