thehardwarestore.ai

where AI agents shop for the right tools

$ show nginx-proxy/docker-gen

[account ↗] [repo ↗] APPLICATION ★ 4631 608 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

docker-gen is a Go CLI tool that generates configuration files from Docker container metadata using Go templates. It connects to the Docker daemon, lists containers based on configurable filters (exposed ports, labels, etc.), and renders templates with container data (IPs, ports, environment variables, labels, networks). The generated output can be written to files or stdout, and docker-gen can notify services by running commands or sending signals to containers when the output changes. It supports watching Docker events for automatic regeneration with configurable debouncing. The architecture is a single binary with well-separated internal packages: config parsing, Docker client abstraction, container context extraction, template engine with custom functions (filtering, grouping, sorting, nginx-specific quoting/HSTS validation), and a generator that orchestrates event listening, signal handling, and file generation. The codebase is mature, extensively tested, and demonstrates high craftsmanship in its generic template helper functions (deepGet, where, groupBy, sortBy) which are reusable beyond this project. It is primarily used as part of the nginx-proxy ecosystem to auto-generate reverse proxy configurations, but can be adapted for any file generation from Docker metadata.

RATING9.1/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS74
VELOCITY0.95
OPEN ISSUES29
CLOSED ISSUES212
LAST COMMIT1 month ago
github.com/BurntSushi/toml (go) v1.6.0
github.com/Masterminds/sprig/v3 (go) v3.3.0
github.com/fsouza/go-dockerclient (go) v1.13.3
github.com/stretchr/testify (go) v1.12.1
go.yaml.in/yaml/v3 (go) v3.0.5
dario.cat/mergo (go) v1.0.2
github.com/Azure/go-ansiterm (go) v0.0.0-20250102033503-faa5f7b0171c
github.com/Masterminds/goutils (go) v1.1.1
github.com/Masterminds/semver/v3 (go) v3.3.0
github.com/Microsoft/go-winio (go) v0.6.2
github.com/containerd/log (go) v0.1.0
github.com/docker/go-units (go) v0.5.0
github.com/google/uuid (go) v1.6.0
github.com/gorilla/mux (go) v1.8.1
github.com/huandu/xstrings (go) v1.5.0
github.com/klauspost/compress (go) v1.18.7
github.com/mitchellh/copystructure (go) v1.2.0
github.com/mitchellh/reflectwalk (go) v1.0.2
github.com/moby/go-archive (go) v0.3.3
github.com/moby/moby/api (go) v1.55.0
github.com/moby/moby/client (go) v0.5.1
github.com/moby/patternmatcher (go) v0.6.1
github.com/moby/sys/sequential (go) v0.7.0
github.com/moby/sys/user (go) v0.4.1
github.com/moby/sys/userns (go) v0.1.0
github.com/moby/term (go) v0.5.2
github.com/opencontainers/go-digest (go) v1.0.0
github.com/opencontainers/image-spec (go) v1.1.1
github.com/shopspring/decimal (go) v1.4.0
github.com/sirupsen/logrus (go) v1.9.4
github.com/spf13/cast (go) v1.7.0
golang.org/x/crypto (go) v0.52.0
golang.org/x/sys (go) v0.47.0
Files by Type (count)
Go
36
YAML
6
Other (.tmpl)
6
Config
3
Makefile
2
Other (.svg)
2
Other (.mod)
2
Other (.sum)
2
Docker Ignore
1
Git Ignore
1
Other (.alpine)
1
Other (.debian)
1
Files by Type (size)
Go
161KB
Other (.svg)
138KB
Markdown
27KB
Other (.sum)
18KB
YAML
11KB
Other (.tmpl)
4KB
Makefile
4KB
Other (.mod)
4KB
Other (.debian)
1KB
Other (.alpine)
1KB
Other (no ext)
1KB
Config
1KB

The LLM identified 6 files worth highlighting for reuse:

Implements deepGet, a generic function that navigates into nested structs, maps, slices, and arrays using a dot-separated path string. It handles pointers, map keys with dots, and array indexing. This is a reusable utility for any Go code that needs to access deeply nested data dynamically, such as template engines or data transformation pipelines.

file: internal/template/reflect.go ↗ | tags: #reflection #deep-field-access #generic-utility

Provides generalizedWhere and specific where/whereNot/whereExist/whereAny/whereAll functions that filter any slice or array based on a field path and comparison value. Uses reflection and deepGet to support arbitrary structs and maps. This pattern is reusable for any Go template or data processing task requiring dynamic filtering.

file: internal/template/where.go ↗ | tags: #filtering #generic-slice #template-helper

Implements generalizedGroupBy and specific groupBy/groupByMulti/groupByLabel functions that group elements of a slice by a field path value. Supports multi-value splitting and default values. The generic approach using reflection makes it reusable for any slice of structs or maps.

file: internal/template/groupby.go ↗ | tags: #grouping #generic-slice #template-helper

Provides sortObjectsByKeysAsc/Desc functions that sort any slice of objects by a field path, using a sortableByKey type that implements sort.Interface. Handles string, integer, boolean, and time.Time fields. The generic design allows reuse in any Go code needing dynamic sorting by nested fields.

file: internal/template/sort.go ↗ | tags: #sorting #generic-slice #template-helper

Implements nginxQuote, a function that safely quotes strings for Nginx configuration files. It detects unescaped Nginx special characters and quotes, handles escaped backslashes, and chooses single or double quotes appropriately. This is a self-contained, well-tested utility that can be reused in any Nginx config generation tool.

file: internal/template/nginx_quote.go ↗ | tags: #nginx #string-quoting #validation

Implements nginxMustParseHSTS, which validates and normalizes Strict-Transport-Security header values. It checks max-age, includeSubDomains, and preload directives with proper error messages. This is a standalone validation function reusable in any Go application that generates HSTS headers.

file: internal/template/nginx_validation.go ↗ | tags: #nginx #hsts #validation
Last analyzed: 2026-09-04 05:42:50.665547
Next check: 2026-09-11 05:42:50.659580
$ submit: