Containerise an App With a Lean Dockerfile and Compose File

AU Business & Compliance Claude intermediate

Get a multi-stage Dockerfile, docker-compose.yml and .dockerignore tailored to your stack — non-root, healthchecked, secrets kept out of the image.

When to use it: When an app runs fine on your machine and needs to run the same everywhere — dev laptops, a VPS, a client's server — without hand-installed dependencies.
You are a DevOps engineer who writes minimal, production-sane container setups. Small images, explicit versions, no secrets baked in.

<context>
App: [APP — e.g. Node 20 Express API, TypeScript, built with npm run build]
Start command: [START — e.g. node dist/index.js]
Port: [PORT — e.g. 5000]
Backing services: [SERVICES — e.g. PostgreSQL 16 and Redis, dev only — production DB is managed]
Environment variables it needs: [ENV — e.g. DATABASE_URL, STRIPE_SECRET_KEY, PORT]
Anything unusual about the build: [QUIRKS — e.g. sharp needs native deps / none]
</context>

Before writing files, state your image plan in two lines: base image and tag (prefer slim official images pinned to my stated versions), and whether a multi-stage build applies (it does whenever there's a compile step).

Then produce three code blocks plus notes:
1. Dockerfile — multi-stage if applicable, dependency layer cached before source copy, production dependencies only in the final stage, a non-root user, EXPOSE for my port, and a HEALTHCHECK appropriate to the app. Comment each section in one line.
2. docker-compose.yml — my app plus only the backing services I listed, pinned image tags, named volumes for anything stateful, ports mapped, environment supplied via an env file reference — with a comment that the env file must never be committed. Include depends_on with a healthcheck condition where startup order matters.
3. .dockerignore — node_modules-equivalents, env files, git, build artefacts.
4. Run notes: build command, first run, how to check the healthcheck is passing, how to view logs, and the one-liner to rebuild after a code change.
5. A sanity list: expected rough image size class (e.g. 'a couple of hundred MB, not gigabytes'), and the two most common reasons this exact stack's build breaks.

Rules: use only my stated versions, ports and services — no invented framework flags. Unknowns become [NEEDED: …]. If my start command and build description conflict, ask before writing.

Copy the block above straight into Claude — anything in [BRACKETS] is yours to fill in.

Want it tuned to your business? Bring it to the free weekly call and we'll adapt it live.

Join the free call

More au business & compliance prompts

Plain-English Contract Summariser

Understand what you're signing before you sign it — and know what to ask a professional

Set Up Redirects and Caching on an Apache Site

Get a ready-to-paste .htaccess block with redirects, HTTPS forcing and caching, plus install, test and undo steps.

Script a Hard Conversation Before You Have It

Turn a dreaded workplace conversation into a short, direct script with openers, key lines and responses to likely reactions.