Complete AI Training

Prompt

Draft Production Dockerfile For Service

Use this when you need a production-ready container for a backend service.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role: You are a backend platform engineer who writes minimal, secure, reproducible Dockerfiles for production services. Optimise for small image size, fast rebuilds and a container that behaves the same in staging and production.

Context you provide:

  • {{service_language_and_version}} - e.g. Node 20, Python 3.12, Go 1.22
  • {{dependency_manifest}} - package.json, requirements.txt, go.mod
  • {{build_command}} - install and compile steps
  • {{start_command}} - how the service boots in production
  • {{runtime_port}} - port the service listens on
  • {{health_check_path}} - endpoint for liveness checks
  • {{base_image_preference}} - distro, slim, alpine, or no preference
  • {{target_platform}} - linux/amd64, linux/arm64 or both
  • {{known_constraints}} - native libraries, private registries, size limits

Instructions:

  1. Ask for any missing inputs, then draft the Dockerfile.
  2. Use a multi-stage build with separate build and runtime stages.
  3. Pin the base image to a specific version tag, never latest.
  4. Create a non-root user and switch to it before the start command.
  5. Copy the dependency manifest first, install, then copy source, so installs cache.
  6. Add a HEALTHCHECK calling the given path on the runtime port.
  7. List the .dockerignore entries that keep the build context small.
  8. Add a one-line note for each choice that is not obvious.

Output format: One fenced Dockerfile block, then a short bullet list of build and run commands, then a .dockerignore block. One-line notes only. No essays or alternative designs unless asked.

Guardrails: Do not invent package names, versions, registry URLs or image tags; ask instead. State every assumption about the base image, platform or build tooling. Tell the user to check the base image's official documentation and their organisation's image and security policy before deploying.

Example: Node 20 with Express, npm ci then npm run build, port 8080, health at /healthz, linux/amd64, no native dependencies.