$ recombobulate _
home / tips / ask-claude-to-write-a-dockerfile-for-your-project-by-reading-the-codebase
143

Ask Claude to Write a Dockerfile for Your Project by Reading the Codebase

recombobulate @recombobulate · Mar 30, 2026 · Workflows
ask-claude-to-write-a-dockerfile-for-your-project-by-reading-the-codebase

Writing a Dockerfile from scratch means knowing the right base image, the right build steps, which files to copy, which ports to expose, and how to keep the image small. Claude can figure all of that out by reading your project.

> read my project and write a production-ready Dockerfile

Claude inspects your package.json, composer.json, requirements.txt, or whatever dependency files exist, checks your build scripts, reads your config to find the port and entry point, and generates a Dockerfile that matches your actual setup — not a generic template.

You can be specific about what you need:

> write a multi-stage Dockerfile that builds the frontend with npm
> and serves the PHP app with nginx and php-fpm

> create a Dockerfile optimized for small image size — use alpine
> base images and minimize layers

> write a Dockerfile and docker-compose.yml for local development
> with hot reload, a database, and Redis

Claude reads your code to make decisions a generic template can't:

  • Base image — picks the right version based on your runtime requirements
  • Dependencies — installs only what your project actually uses
  • Build steps — runs your actual build commands in the right order
  • Multi-stage builds — separates build-time and runtime dependencies to keep images lean
  • Security — runs as a non-root user, copies only necessary files, uses .dockerignore patterns

Ask Claude to generate a .dockerignore file at the same time:

> also create a .dockerignore that excludes tests, docs, node_modules,
> and anything else that doesn't belong in the production image

If you already have a Dockerfile that works but is bloated or slow, paste it and ask Claude to optimize:

> this Dockerfile works but the image is 2GB and builds take 10 minutes —
> optimize it for size and build speed

A good Dockerfile is project-specific — let Claude read yours and build it right.

via Claude Code

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago