Review a Dockerfile for size and safety
Reviews a Dockerfile for image size, build speed and security habits, then returns one improved version with each change explained.
Task:
Review the Dockerfile below for image size, build speed and security habits, and give me one improved version.
Context:
The app is [language and framework] and runs as [web service, worker or CLI]. The base image I use now is [base image]. The image is deployed to [where it runs].
Rules:
- Read every instruction in order before commenting, including copy and layer order.
- Check the base image choice, layer caching, a non-root user, files copied that should not be, and build-time secrets.
- Do not claim exact size savings. Say which changes should shrink the image and how I measure it.
- If the file passes a secret or key in an argument or environment line, say so and tell me to rotate it. Ask for no real secrets in the chat.
- Explain any suggested command that deletes images, volumes or containers before you give it.
Result:
A numbered list of at most 6 findings ranked by impact, then the improved Dockerfile in one code block with a comment on each changed line.
Material:
[paste the Dockerfile here]