Skip to content

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
CommandPurpose
analyzeScan the current Dockerfile and surface risks
benchmarkBuild and score the current Dockerfile
evolveGenerate and benchmark multiple candidate genomes
compareCompare Dockerfile with Dockerfile.optimized
optimizeRun 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

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages