Skip to content

mah404/dockergenome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dockergenome

Evolve better Dockerfiles.

npx dockergenome optimize

Why it exists

Dockerfiles tend to accrete over time: extra layers, expensive cache misses, oversized base images, and package-manager leftovers. dockergenome treats your Dockerfile like a genome:

  1. analyze the source
  2. create safe variants
  3. build them with Docker
  4. measure real outcomes
  5. keep the best-performing result

The result is a smaller, cleaner Dockerfile without overwriting your original.

Features

  • Automatic Dockerfile analysis — base image, layers, install commands, cache behavior, image-size risks
  • Evolutionary optimization — image swaps, layer merging, cleanup insertion, dependency-copy reordering
  • Real benchmarking — actual docker build timing, image inspection, failure handling
  • Terminal-first UX — neon banner, spinners, mutation logs, leaderboard output
  • Safe by default — original Dockerfile backup, no destructive overwrite, failed variants discarded
  • Portfolio-ready artifacts — optimized Dockerfile, markdown report, and web landing page

Installation

npm install -g dockergenome

Or run directly:

npx dockergenome optimize

Commands

dockergenome analyze
dockergenome benchmark
dockergenome evolve
dockergenome compare
dockergenome optimize
Command Purpose
analyze Scan the current Dockerfile and surface risks
benchmark Build and score the current Dockerfile
evolve Generate and benchmark multiple candidate genomes
compare Compare Dockerfile with Dockerfile.optimized
optimize Run the full pipeline and write final artifacts

Example session

◈ Genome scan complete
  Base image: node:20
  Layers: 3
  RUN instructions: 2
  COPY instructions: 1
  Score: 64/100

◈ Evolution leaderboard
  Variant     Status   Time      Size        Layers   Score
  -----------------------------------------------------------
  g1-v2       PASS     23104     212.40MB    2        550.72
  seed        PASS     24780     382.81MB    3        205.18

Output files

  • Dockerfile.optimized
  • genome-report.md
  • benchmark-summary.json
  • Dockerfile.backup

Architecture

flowchart LR
  A["CLI"] --> B["Analyzer"]
  A --> C["Evolution Engine"]
  C --> D["Mutator"]
  C --> E["Benchmark Runner"]
  E --> F["Docker CLI"]
  C --> G["Leaderboard"]
  G --> H["Markdown Report"]
Loading

How it works

dockergenome intentionally uses conservative mutations:

  • swap known large base images for slim equivalents
  • merge RUN layers where safe
  • add package-manager cache cleanup
  • split dependency-manifest copies from application copies to improve cache reuse

Each candidate is built in isolation. Failed builds are preserved in the leaderboard as failed experiments, but they are never selected as the winning genome.

Screenshot placeholders

Add terminal captures here after your first real benchmark run.

  • docs/screenshots/leaderboard.png
  • docs/screenshots/report.png
  • docs/screenshots/landing-page.png

Development

npm install
npm run build
npm run dev -- optimize

Roadmap

  • configurable mutation strategies
  • support for multi-objective scoring profiles
  • Docker BuildKit cache metrics
  • runtime benchmark hooks
  • richer diff output between candidate genomes
  • OCI registry publishing workflows

Future AI ideas

  • LLM-assisted mutation proposals
  • historical learning from previous runs
  • workload-aware optimization profiles
  • autonomous remediation suggestions for build failures

License

MIT

About

Dockerfiles tend to accrete over time: extra layers, expensive cache misses, oversized base images, and package-manager leftovers. `dockergenome` treats your Dockerfile like a genome:

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors