Dockerfile Optimizer

intermediateopsMin 16K context

Reviews and rewrites Dockerfiles for smaller images, faster builds, and better security. Applies multi-stage builds, optimal layer ordering and caching, minimal base images, non-root users, and .dockerignore tuning, and flags vulnerabilities and bloat while keeping the build reproducible.

Use Cases

  • Shrinking image size with multi-stage builds and slim bases
  • Reordering layers to maximize build cache hits
  • Running containers as a non-root user
  • Tuning .dockerignore to cut build context
  • Flagging insecure or outdated base images

Example Prompt

Optimize this Dockerfile for size, build speed, and security without changing runtime behavior.

```dockerfile
FROM node:20
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
CMD ["node", "dist/index.js"]
```

Provide the rewritten Dockerfile, a matching .dockerignore, and an explanation of each change.

Recommended Models

Compatible Tools

claude-codecursorkiroany

Modalities

Input: code, text
Output: code, text

Related Skills

Author

OpenModels Community

@openmodelsrun