dockgen-0.1.0 is not a library.
dockgen
Smart minimal Dockerfile generator — languages, frameworks & multi-service projects.
DockGen scans a project directory, detects languages, frameworks, and package managers, analyses service boundaries (monorepo-aware), and emits production-grade, security-hardened Dockerfiles and .dockerignore files with zero manual intervention.
Key Features
- 30+ Framework Support — Next.js, Nuxt, NestJS, FastAPI, Django, Flask, Gin, Echo, Axum, Actix Web, Spring Boot, Laravel, Rails, ASP.NET Core, and more.
- Monorepo Intelligence — Automatic detection of Turborepo, pnpm workspaces, Nx, Lerna, Cargo workspaces, and Go modules. Per-service Dockerfiles with correct build contexts.
- Secure by Default — Every generated Dockerfile uses non-root users (
USER appuser), multi-stage builds, and minimal base images (Alpine/Slim). - Cache-Efficient Builds — Manifests and lockfiles are copied first, dependencies installed, then source code layered on top.
- Deterministic Output — Same input always produces byte-identical output. Sorted services, sorted files.
- Zero Runtime Dependencies — Single static binary. No Node, Python, or Docker required to generate files.
- Docker Compose Generation — Optionally emit a
docker-compose.ymlwith correct port mappings and environment variables. - Infrastructure Detection — Automatically detects PostgreSQL, MySQL, Redis, MongoDB, RabbitMQ, Kafka, and SQLite from env vars, manifest dependencies, and Prisma schemas. Emits compose services with healthchecks and named volumes.
- JSON Output Mode — Machine-readable analysis and generation results for CI/CD integration.
- Interactive Wizard —
-iflag activates adaptive Q&A for infrastructure selection, Prisma migrations, Laravel queue workers, and port confirmations.
Supported Languages & Frameworks
| Language | Frameworks | Base Images |
|---|---|---|
| Node.js | Next.js, Nuxt, NestJS, Express, Fastify, Remix, SvelteKit, Astro, Generic | node:<ver>-alpine |
| Python | FastAPI, Django, Flask, Starlette, Litestar, Generic | python:<ver>-slim |
| Go | Gin, Echo, Fiber, Chi, Generic | golang:<ver>-alpine → alpine:3.19 |
| Rust | Axum, Actix Web, Rocket, Warp, Generic | rust:<ver>-slim → debian:bookworm-slim |
| Java | Spring Boot, Quarkus, Micronaut, Generic | eclipse-temurin:<ver>-jre-alpine |
| PHP | Laravel, Symfony, Generic | php:<ver>-fpm-alpine |
| .NET | ASP.NET Core, Generic | mcr.microsoft.com/dotnet/aspnet:<ver>-alpine |
| Ruby | Rails, Sinatra, Generic | ruby:<ver>-slim |
| Generic | Any | alpine:3.19 |
Installation
From crates.io
From source
Pre-built binaries
Download the latest binary from GitHub Releases for your platform.
Usage
Automatic detection (simplest)
# Scan current directory and generate files
# Scan a specific project
# Preview without writing to disk
Language & framework overrides
# Force Rust + Axum detection
# Force Python + FastAPI
# Force Node.js + Next.js
Monorepo handling
# Auto-detect monorepo and generate per-service Dockerfiles
# Generate only for specific services
# Force single unified Dockerfile
Port & base image overrides
# Override ports for services (in order)
# Prefer Alpine base images
Docker Compose generation
# Generate docker-compose.yml alongside Dockerfiles
# Combine with other flags
JSON output (CI/CD)
# Get structured JSON output
# Pipe to jq for filtering
|
Interactive mode
# Enable interactive wizard for infrastructure selection
# Combine with compose for guided setup
Quiet mode
# Suppress all output except errors
# Combine with JSON for clean machine output
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ CLI (clap v4) │
│ path · lang · fw · services · port · base · compose · dry-run │
└──────────────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Analysis Pipeline │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Structure │→ │ Language │→ │ Framework │ │
│ │ Detector │ │ + PM Det. │ │ + Version Extract │ │
│ │ (workspace, │ │ (manifests, │ │ (per-ecosystem │ │
│ │ monorepo) │ │ extensions)│ │ detectors) │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────┐ │
│ │ ProjectAnalysis │ │
│ │ (services, warnings│ │
│ │ monorepo flag) │ │
│ └─────────┬───────────┘ │
└──────────────────────────────┼──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Generation Pipeline │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Dockerfile │ │ .dockerignore│ │ docker-compose.yml │ │
│ │ Generator │ │ Generator │ │ Generator (opt.) │ │
│ │ (per-svc, │ │ (per-svc + │ │ (services, ports, │ │
│ │ tera tpl) │ │ root) │ │ env vars) │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────┐ │
│ │ GeneratedFile(s) │ │
│ │ (sorted, ready) │ │
│ └─────────┬───────────┘ │
└──────────────────────────────┼──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Output Layer │
│ │
│ dry-run: formatted stdout display │
│ write: safe disk write (create_dir_all + fs::write) │
│ json: structured JSON to stdout │
└─────────────────────────────────────────────────────────────────┘
Generated Dockerfile Standards
Every Dockerfile produced by DockGen follows these elite container standards:
- Multi-stage builds — Separate builder and runtime stages to minimize image size.
- Non-root execution —
USER appuserorUSER 10001in every runtime stage. - Cache-efficient ordering — Manifests/lockfiles copied first, dependencies installed, then source code.
- Minimal base images — Alpine or Slim variants by default. Distroless available via
--base distroless. - Explicit EXPOSE/ENV — Port declarations and environment variables clearly stated.
- No secrets — Never emits tokens, passwords, or API keys in ENV directives.
- PHP/Laravel hardened — Includes
pdo_mysql+pdo_pgsqlextensions for multi-database support. - Java/Spring Boot safe — Explicit
chmod +xforgradlew/mvnwwrapper scripts.
CLI Reference
| Flag | Short | Description |
|---|---|---|
--lang |
-l |
Override detected language |
--fw |
-f |
Override detected framework |
--services |
-s |
Filter specific services (comma-separated) |
--single |
Force single unified Dockerfile | |
--base |
-b |
Base image variant (alpine/slim/distroless/default) |
--compose |
-c |
Generate docker-compose.yml |
--port |
-p |
Override exposed ports (comma-separated, in order) |
--dry-run |
Preview generated files without writing | |
--json |
Output structured JSON | |
--output-dir |
-o |
Custom output directory |
--interactive |
-i |
Activate interactive Q&A wizard |
--yes |
-y |
Accept all defaults (non-interactive mode) |
--verbose |
-v |
Enable debug tracing |
--quiet |
-q |
Suppress all output except errors |
License
Licensed under either of MIT or Apache-2.0 at your option.