BACK TO TEMPLATES
promptany
Dockerfile Security and Layer Optimizer Prompt
Prompt for analyzing and optimizing Dockerfiles for multi-stage caching, security hardening, and image size reduction.
When to use this
Use this prompt to audit Dockerfiles for layer caching optimization, security hardening, and minimal image size.
The template
Refactor and optimize the provided Dockerfile. Requirements: 1. Implement multi-stage builds separating build tools from runtime execution dependencies. 2. Optimize layer caching order (copy dependency manifests `package.json`/`requirements.txt` before source code). 3. Ensure runtime executes under a unprivileged user (`USER 10001`). 4. Minimize final image size by clearing build caches and using Alpine/Distroless bases. Dockerfile to Optimize: ```dockerfile [PASTE DOCKERFILE HERE] ```
How to use
Paste your unoptimized Dockerfile into the template.
Last verified 2026-07-26