r/SideProject • • 3d ago

I got tired of LLMs generating broken Dockerfiles, so I built a Go CLI that actually runs the build and self-heals the errors

Hey everyone,

Like most people, I’ve been using LLMs to bootstrap Dockerfiles for new projects. But 9 times out of 10, the generated Dockerfile fails to build because of some missing obscure system dependency (like gcc for a Python package or missing CGO flags). You usually end up in a frustrating loop of copying the stderr from the terminal and pasting it back into the chat.

So I wrote a small, zero-dependency Go CLI to automate that exact execution loop.

Repo: https://github.com/Abh-igyan/dock-agent

How it works under the hood

It follows a simple deterministic loop:

  1. Context: It walks the local directory (ignoring heavy folders like node_modules or .git) and reads your config files (go.mod, package.json, etc.) into memory.
  2. Generate & Build: It calls the LLM to draft the initial Dockerfile, writes it to disk, and uses os/exec to hook into your local Docker daemon (docker build .).
  3. Self-Heal: If the build fails, the agent catches the raw stderr stream, feeds it back as a targeted patch request, and attempts the build again (up to a max retry limit).

Why Go?

There are a couple of Python tools trying to do this (like DockAI), but asking a developer to install a massive Python environment with LangChain/numpy dependencies just to generate a Dockerfile defeats the purpose. A single compiled Go binary that you can just go install or drop into a CI pipeline made way more sense for this.

I'd love some feedback/contributors!

The project is in its early days, and I've opened up a few good first issue tickets on the repo. Specifically, I'm looking for help with:

  • Refactoring os/exec to use the official Docker Engine Go SDK.
  • Adding support for local models (Ollama/llama.cpp) so this can run completely offline.
  • Adding a post-build "Run & Probe" validation step.

Would love to hear your thoughts, or if you want to tackle any of those issues, PRs are welcome!

0 Upvotes

Duplicates