🚀

Docker Multi-Stage Build Optimizer

Optimize Docker builds for smaller images and faster CI

Intermediate🚀 DevOpsAll Models
prompt template
Optimize the Docker build for this application:

**Application type:** [TYPE — e.g., "Next.js app", "Node.js API", "Python FastAPI"]
**Current image size:** [SIZE — e.g., "1.2GB"]
**Current build time:** [TIME — e.g., "8 minutes"]

Generate an optimized Dockerfile with:
1. **Multi-stage build** — separate build, test, and production stages
2. **Layer caching** — order instructions for maximum cache reuse
3. **Minimal base image** — alpine or distroless with security justification
4. **Dependency caching** — cache node_modules/pip packages across builds
5. **Security hardening** — non-root user, read-only filesystem, no dev dependencies
6. **.dockerignore** — comprehensive ignore file to speed up context transfer
7. **Build arguments** — configurable for different environments

Include the Dockerfile, .dockerignore, and docker-compose.yml for local dev.
Target: production image under 200MB, build time under 3 minutes.

How to Use This Prompt

  1. 1Copy the prompt template above
  2. 2Paste into Claude, ChatGPT, or Cursor
  3. 3Replace [bracketed placeholders] with your specific project details
  4. 4Iterate on the AI output to refine and customize the results