Skip to main content

Claude/ChatGPT Prompt to Build a Local Dev Stack with Observability

Generate a complete docker-compose.yml that runs your app with Postgres, Redis, Prometheus, Grafana, and tracing for full local-dev observability.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt makes the AI a senior DevOps engineer that writes a complete, working docker-compose.yml for a local dev stack with built-in observability, returning the full file rather than a sketch. You set the [app_service] image or build command, the [app_port], the [database], and the [tracing_backend]. It returns a compose file running your app alongside Postgres, Redis, Mailhog, Prometheus, Grafana, and the chosen tracing backend, with an env-file reference for secrets and connection strings, healthchecks and depends_on using condition service_healthy, persistent named volumes for the database and Grafana, a Prometheus scrape config and pre-provisioned Grafana datasource, and a short first-run guide.

The structure works because it wires healthchecks and ordered startup with depends_on so the app doesn't race the database on cold start, which is the failure that makes a fresh stack flaky on the first run. [app_service] and [app_port] slot your application into the stack and expose it on the right port. [database] pins the database image and version so connection strings and behaviour match production. [tracing_backend] chooses between tracing tools so the pre-provisioned datasource and the first-run trace instructions point at the right service. The result mirrors production locally, including traces and metrics, so bugs surface on your laptop instead of in production.

When to use it

  • You want local dev to mirror production, including traces.
  • You want a new developer productive with one command.
  • Your app keeps racing the database on cold start.
  • You want metrics and tracing wired in without manual Grafana setup.
  • You need Mailhog to catch outbound email locally.
  • You want persistent volumes so local data survives restarts.

Example output

You get a complete docker-compose.yml defining your app plus Postgres, Redis, Mailhog, Prometheus, Grafana, and your chosen tracing backend, with healthchecks, ordered startup via depends_on with condition service_healthy, persistent named volumes for the database and Grafana, an env-file reference for secrets and connection strings, a Prometheus scrape config, and a pre-provisioned Grafana datasource. Alongside it are the supporting config files and a short first-run guide listing bring-up order, service URLs, and how to view traces, so a new developer gets a working stack in one command.

Pro tips

  • Set [app_service] to your real image or build-and-command so the app slots straight in.
  • Match [app_port] to what your app listens on so the exposed port is correct.
  • Pin [database] to the exact version you run in production for parity.
  • Choose [tracing_backend] deliberately; it sets the datasource and trace-viewing steps.
  • Trust the healthchecks; they are what stop the app racing the database on cold start.
  • Keep the named volumes so your local database and dashboards persist across restarts.

Frequently Asked Questions

Does it stop my app from racing the database on startup?
Yes. It wires healthchecks with depends_on using condition service_healthy, so the app waits until the database reports healthy before starting. Getting these healthchecks right is exactly what prevents the cold-start race where the app boots before the database is ready to accept connections.
Which observability tools does it set up?
It runs Prometheus and Grafana for metrics with a pre-provisioned datasource and scrape config, plus your chosen `[tracing_backend]` for traces and Mailhog for email. The goal is to mirror production observability locally so bugs surface on your laptop instead of in production.
Can I use a different database than Postgres?
The compose file is built around the `[database]` you specify, so you set the image and version there. The other services like Prometheus and Grafana are fixed, but the database service adapts to your value. Pin it to your production version so local connection strings and behaviour match.
Will my local data survive a restart?
Yes, the prompt requires persistent named volumes for the database and Grafana data, so your local records and dashboards survive container restarts. If you want a clean slate you can remove the volumes manually, but by default the stack is set up to keep your data between runs.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Docker & Kubernetes Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support