What problem does it solve?
This skill ensures that application environments are reproducible, secure, and production-ready using Docker and modern containerization practices.
Core Features & Use Cases
- Multi-stage builds are mandatory: Enforce separate builder and runner stages to keep production images lean.
- Least Privilege (Never run as root): Always create non-root users and switch to them in the final image.
- Layer Caching & Immutability: Copy dependency manifests first and install to leverage Docker's layer caching.
Core Rules for Docker Compose (Local Dev)
- Persistence: Use named volumes for databases and brokers to avoid data loss on restarts.
- Healthchecks & Dependency Ordering: Add healthchecks and use depends_on with condition: service_healthy.
- Environment Variables: Do not hardcode secrets; use .env files or environment interpolation.
Workflow
- Analyze Stack: Determine language, framework, and required external services (DB, Cache).
- Draft Dockerfile: Create an optimized, multi-stage Dockerfile.
- Draft Compose: Create a docker-compose.yml for local development.
- Explain: Briefly explain to the user how to start the environment.
Quick Start
Set up a reproducible local environment for a sample app using a multi-stage Dockerfile and docker-compose.