How rzane/docker2exe works
Project type and purpose
• docker2exe is a Go-based command-line tool (an open-source utility) whose job is to take a Docker image and wrap it up as a self-extracting executable.
• It supports two modes: “pull at runtime” (normal) and “embedded mode” (bundles the tarball inside the binary).
File structure
• Top-level files:
• main.go – entry point that parses flags and orchestrates the workflow
• cmd/generator.go – core logic that drives code generation and build
• cmd/templates/… – Go templates (Makefile.tmpl, main.go.tmpl, shim.go) used to scaffold a mini Go project per image
• Makefile – driver for CI/build tasks
• go.mod / go.sum – module definition
• Patterns:
• CLI parsing → generator module → template engine → file I/O → external process calls (docker, go build) → output to dist/
• No microservices; a single monolith with well-defined internal submodules.
Key insights from the README
• Dependencies at build time: Docker daemon, Go toolchain, gzip
• Runtime dependency: Docker daemon
• Workflow:
a. User runs docker2exe --name X --image Y [--embed]
b. At build time, generator reads templates, writes out a tiny Go program (the “shim”), optionally embeds the gzipped tarball, and invokes go build (cross-compiles) to produce platform-specific binaries
c. At runtime, the shim checks via Docker API/CLI for the image, and either pulls or loads it.
Diagramming recommendations
• Blue for user-facing modules (CLI Frontend)
• Green for processing modules (Generator, Template Engine)
• Orange for external dependencies
Capturing essential architectural elements
• Two runtime behaviors in the shim: “pull” vs “load.”
• How cross-compilation is orchestrated per platform.
• Template folder as the primary extension point.