prompt

Dockerfile Generator

Generates a production-ready, optimized Dockerfile for a given stack.

VettedUpdated June 2026
The prompt
You are a DevOps engineer. Write a production-ready Dockerfile for the application below.

Inputs:
- Stack/runtime + version: {{stack}}
- App details (entrypoint, port, build step): {{app}}
- Constraints: {{constraints}} (image size, multi-stage, non-root, etc.)

Produce:
1. A commented Dockerfile that follows best practices: pinned base image, multi-stage build where it helps, dependency caching layer before copying source, a non-root user, and the correct EXPOSE/CMD.
2. A short note on each key decision (why multi-stage, why this base, why the layer order).
3. A matching .dockerignore suggestion.
4. One security/size tip specific to {{stack}}.

Rules: pin the base image version (no :latest); order layers for cache efficiency (deps before source); run as non-root unless {{constraints}} say otherwise; don't bake secrets into the image \u2014 note to use build args/runtime env. Flag anything in {{app}} that's unclear.
Did it work? Rate this prompt

Variables

{{stack}}Stack/runtime + version
{{app}}App details
{{constraints}}Constraints

Example output

Stack: Node 20, Express. App: entry server.js, port 3000, npm build step. Constraints: small image, non-root. # ---- build stage ---- FROM node:20-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # ---- runtime stage ---- FROM node:20-alpine WORKDIR /app ENV NODE_ENV=production COPY package*.json ./ RUN npm ci --omit=dev && npm cache clean --force COPY --from=build /app/dist ./dist USER node EXPOSE 3000 CMD ["node", "dist/server.js"] Decisions: multi-stage keeps dev deps + build tools out of the final image (smaller, safer); copying package files before source means npm layers cache unless deps change; alpine base for size; USER node runs non-root. .dockerignore: node_modules, .git, .env, dist, npm-debug.log, Dockerfile Tip: don't COPY .env \u2014 pass secrets at runtime via env vars or a secrets manager.

Details

Author

AI Khazna

License

Security

Vetted

Type

prompt

Related assets

More curated picks in Development & Code.

Audit before you install

Run any source through our checks - AI visibility, security, performance, and stack detection.

More in Development & Code