Build a secure multi-stage Dockerfile for web apps
Produce a production-grade, secure, multi-stage Dockerfile tailored to your runtime. Use it when containerizing a web backend or frontend application.
Prompt
Act as a DevOps and container security engineer. You will create an optimized, secure multi-stage Dockerfile and matching .dockerignore file for my application.
First, ask me 3 short numbered questions in one message and wait for my response:
1. What is your programming language and framework runtime (e.g., Node 20, Python 3.12, Go 1.22)?
2. What package manager and build command does your app require (e.g., npm run build, poetry, cargo)?
3. Does the app serve static assets, run as a long-lived web server, or need specific OS libraries?
After I answer, output:
1. Dockerfile (fenced code block with multi-stage build, layer caching, non-root user, and dumb-init/tini where appropriate)
2. .dockerignore file (fenced code block)
3. Build and run commands (terminal snippet)
4. Security & size checklist (short bullet points)Example output
Copy and paste this prompt into Gemini, ChatGPT, or Claude. Answer the three questions the model asks, then ask for a docker-compose.yml file as a follow-up.
Make it repeatable
Keep using this prompt without pasting it in every time.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
Rebuild local setup instructions from project config files
Extract prerequisites and start commands from package files, Docker configs, or env templates. Use this to onboard teammates when README files are missing or broken.
Build and verify a cron schedule expression
Convert your desired job schedule into an exact cron expression with clear plain-English breakdown and upcoming run dates.
Create safe user error messages with correlation IDs
Turn internal backend exceptions into secure, user-facing error payloads paired with traceable request correlation IDs. Use it to build clean API error contracts.
Find the failing line in a stack trace
Isolate your application code from noisy framework trace logs and explain the root runtime crash. Use it when debugging confusing error logs.
Generate complete API documentation from route code
Generate clear request, response, and error documentation directly from backend handler code. Use it to prepare API docs for frontend developers.
Convert raw error logs into a clean bug report
Turn noisy console dumps or stack traces into structured bug tickets. Use this when triage is stalled by messy logs from test environments or bug trackers.
- Refactor nested legacy loops into flat readable helper functions
- Split a large pull request into reviewable commits
- Write a guided walkthrough for a complex pull request
- Debug SQL query errors and incorrect row counts
- Recover from Git commit or branch mistakes safely
- Write a Google Apps Script to Automate a Repetitive Google Sheets Task