prompt
Dockerfile Generator
Generates a production-ready, optimized Dockerfile for a given stack.
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.
Variables
{{stack}}Stack/runtime + version{{app}}App details{{constraints}}ConstraintsExample 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.
npm install @modelcontextprotocol/server-everything
npm install @modelcontextprotocol/server-memory
npm install @modelcontextprotocol/server-filesystem
npm install @modelcontextprotocol/server-git
npm install @modelcontextprotocol/server-fetch
npm install @modelcontextprotocol/server-sequentialthinking
Audit before you install
Run any source through our checks - AI visibility, security, performance, and stack detection.
Automated Web Security Scan
security
PageSpeed Analyzer
performance
AI Content Quality Test
arabic content
AI Agent / MCP Server Tester
ai testing
Site Stack Detector
migration
AI SEO / AEO / GEO Audit
ai visibility
llms.txt Generator
ai visibility
Readability Score
arabic content
Schema / JSON-LD Builder
ai visibility
AI Cost Calculator
ai testing
Headline Analyzer
arabic content