Instructions
When to Use
- Use for Dockerfile + Compose for Next on Node LTS.
- Prefer
monorepo-toolingfor workspace package graphs first. - Prefer
env-config-agentfor compose secret naming.
Add Docker and Compose for local and CI-like runs of Next.js (Node 20/22 LTS, pnpm).
.dockerignore: exclude.git,node_modules,.next,dist,.env*(use build args or runtime mount for secrets in dev only).- Multi-stage:
deps(pnpm fetch/install) →builder(pnpm build) →runner(minimal:node_modulesprod slice +.next/standaloneif user enabled standalone output - match theirnext.config). - User: non-root
USER nodeor numeric uid in final stage. - Compose:
app+postgres+ optionalredis; healthchecks; named volumes; no secrets in compose YAML -.envlocal only gitignored. - Dev vs prod:
docker compose -f compose.yaml -f compose.override.yamlpattern for hot reload optional - keep prod Dockerfile lean. - CI: same Dockerfile build in GitHub Actions to prove reproducibility - link
github-actions-ci.
Outcomes
- File list + Dockerfile stage names + compose service graph (bullets).
Output Rules
suggest-shell: docker build / compose up commands; user runs them.
Scope and boundaries
- In scope: local dev containers, small prod-oriented images.
- Out of scope: Kubernetes manifests, service mesh, HIPAA hosting.
Safety
- Never print
.envcontents; useenv_file: .env.localdocumentation only.
Troubleshooting
- ARM vs x86: buildx platforms for M-series Mac deploying to amd64 cloud.
- Huge context: fix
.dockerignorebefore chasing layer cache.
Related skills
monorepo-tooling- multi-package Docker contextsgithub-actions-ci- CI image build/cacheenv-config-agent- compose env files
GitHub: https://github.com/bh611627/skillcodex/tree/main/skills/container-local-dev/SKILL.md
npm: https://www.npmjs.com/package/@skillcodex/skills