Documentation
¶
Overview ¶
Package ecosystem detects the language/framework ecosystems present in a Docker image or project directory by looking for well-known lock files and project structure markers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllMarkers = []Marker{ {Path: "package.json", Ecosystem: NodeJS, Label: "npm"}, {Path: "package-lock.json", Ecosystem: NodeJS, Label: "npm"}, {Path: "yarn.lock", Ecosystem: NodeJS, Label: "yarn"}, {Path: "pnpm-lock.yaml", Ecosystem: NodeJS, Label: "pnpm"}, {Path: "bun.lockb", Ecosystem: NodeJS, Label: "bun"}, {Path: "bun.lock", Ecosystem: NodeJS, Label: "bun"}, {Path: "deno.lock", Ecosystem: NodeJS, Label: "deno"}, {Path: "go.mod", Ecosystem: Go, Label: "go modules"}, {Path: "go.sum", Ecosystem: Go, Label: "go modules"}, {Path: "requirements.txt", Ecosystem: Python, Label: "pip"}, {Path: "Pipfile", Ecosystem: Python, Label: "pipenv"}, {Path: "Pipfile.lock", Ecosystem: Python, Label: "pipenv"}, {Path: "pyproject.toml", Ecosystem: Python, Label: "poetry/pip"}, {Path: "setup.py", Ecosystem: Python, Label: "setuptools"}, {Path: "setup.cfg", Ecosystem: Python, Label: "setuptools"}, {Path: "uv.lock", Ecosystem: Python, Label: "uv"}, {Path: "Cargo.toml", Ecosystem: Rust, Label: "cargo"}, {Path: "Cargo.lock", Ecosystem: Rust, Label: "cargo"}, {Path: "pom.xml", Ecosystem: Java, Label: "maven"}, {Path: "build.gradle", Ecosystem: Java, Label: "gradle"}, {Path: "build.gradle.kts", Ecosystem: Java, Label: "gradle"}, {Path: "gradlew", Ecosystem: Java, Label: "gradle"}, {Path: "Gemfile", Ecosystem: Ruby, Label: "bundler"}, {Path: "Gemfile.lock", Ecosystem: Ruby, Label: "bundler"}, {Path: "composer.json", Ecosystem: PHP, Label: "composer"}, {Path: "composer.lock", Ecosystem: PHP, Label: "composer"}, {Path: "mix.exs", Ecosystem: Elixir, Label: "mix"}, {Path: "mix.lock", Ecosystem: Elixir, Label: "mix"}, {Path: "*.csproj", Ecosystem: DotNet, Label: "dotnet"}, {Path: "*.fsproj", Ecosystem: DotNet, Label: "dotnet"}, {Path: "*.vbproj", Ecosystem: DotNet, Label: "dotnet"}, {Path: "global.json", Ecosystem: DotNet, Label: "dotnet"}, {Path: "Directory.Build.props", Ecosystem: DotNet, Label: "dotnet"}, {Path: "nuget.config", Ecosystem: DotNet, Label: "nuget"}, }
AllMarkers is the full list of ecosystem markers we look for.
var EcosystemBloatPatterns = map[Type][]BloatPattern{ NodeJS: { {Pattern: "node_modules/", Description: "Node dependencies — use multi-stage build", Ecosystem: NodeJS}, {Pattern: "node_modules/.cache/", Description: "Build tool caches inside node_modules", Ecosystem: NodeJS}, {Pattern: ".npm/", Description: "npm cache", Ecosystem: NodeJS}, {Pattern: ".yarn/", Description: "Yarn cache", Ecosystem: NodeJS}, {Pattern: ".pnpm-store/", Description: "pnpm store", Ecosystem: NodeJS}, {Pattern: "*.map", Description: "Source maps — strip in production", Ecosystem: NodeJS}, {Pattern: "*.d.ts", Description: "TypeScript declarations", Ecosystem: NodeJS}, {Pattern: ".eslintrc*", Description: "ESLint config", Ecosystem: NodeJS}, {Pattern: ".prettierrc*", Description: "Prettier config", Ecosystem: NodeJS}, {Pattern: "tsconfig*.json", Description: "TypeScript config", Ecosystem: NodeJS}, {Pattern: "jest.config*", Description: "Jest config", Ecosystem: NodeJS}, {Pattern: ".babelrc", Description: "Babel config", Ecosystem: NodeJS}, {Pattern: "webpack.config*", Description: "Webpack config (if pre-built)", Ecosystem: NodeJS}, {Pattern: "storybook/", Description: "Storybook", Ecosystem: NodeJS}, {Pattern: ".storybook/", Description: "Storybook config", Ecosystem: NodeJS}, {Pattern: ".next/cache/", Description: "Next.js build cache", Ecosystem: NodeJS}, }, Go: { {Pattern: "vendor/", Description: "Go vendor directory — use go mod download", Ecosystem: Go}, {Pattern: "*_test.go", Description: "Go test files", Ecosystem: Go}, {Pattern: "testdata/", Description: "Go test data", Ecosystem: Go}, {Pattern: ".golangci.yml", Description: "Linter config", Ecosystem: Go}, {Pattern: ".golangci.yaml", Description: "Linter config", Ecosystem: Go}, {Pattern: "*.test", Description: "Go compiled test binaries", Ecosystem: Go}, }, Python: { {Pattern: "__pycache__/", Description: "Python bytecode cache", Ecosystem: Python}, {Pattern: "*.pyc", Description: "Compiled Python files", Ecosystem: Python}, {Pattern: "*.pyo", Description: "Optimized Python files", Ecosystem: Python}, {Pattern: ".pytest_cache/", Description: "Pytest cache", Ecosystem: Python}, {Pattern: ".mypy_cache/", Description: "Mypy cache", Ecosystem: Python}, {Pattern: ".tox/", Description: "Tox environments", Ecosystem: Python}, {Pattern: "*.egg-info/", Description: "Python egg info", Ecosystem: Python}, {Pattern: "dist/", Description: "Python distribution", Ecosystem: Python}, {Pattern: "build/", Description: "Python build directory", Ecosystem: Python}, {Pattern: ".venv/", Description: "Virtual environment", Ecosystem: Python}, {Pattern: "venv/", Description: "Virtual environment", Ecosystem: Python}, {Pattern: "env/", Description: "Virtual environment", Ecosystem: Python}, {Pattern: ".ruff_cache/", Description: "Ruff linter cache", Ecosystem: Python}, }, Rust: { {Pattern: "target/", Description: "Rust build artifacts", Ecosystem: Rust}, {Pattern: "target/debug/", Description: "Debug build artifacts", Ecosystem: Rust}, {Pattern: "target/release/deps/", Description: "Release dependencies", Ecosystem: Rust}, {Pattern: "*.rs.bk", Description: "Rust backup files", Ecosystem: Rust}, }, Java: { {Pattern: "target/", Description: "Maven build output", Ecosystem: Java}, {Pattern: "build/", Description: "Gradle build output", Ecosystem: Java}, {Pattern: ".gradle/", Description: "Gradle cache", Ecosystem: Java}, {Pattern: "*.class", Description: "Compiled class files", Ecosystem: Java}, {Pattern: "*.jar", Description: "JAR files (use multi-stage)", Ecosystem: Java}, {Pattern: "*.war", Description: "WAR files", Ecosystem: Java}, {Pattern: ".mvn/", Description: "Maven wrapper", Ecosystem: Java}, {Pattern: "*.iml", Description: "IntelliJ module files", Ecosystem: Java}, }, Ruby: { {Pattern: ".bundle/", Description: "Bundler metadata", Ecosystem: Ruby}, {Pattern: "vendor/bundle/", Description: "Vendored gems", Ecosystem: Ruby}, {Pattern: ".rubocop*", Description: "Rubocop config", Ecosystem: Ruby}, {Pattern: "*.gem", Description: "Gem files", Ecosystem: Ruby}, {Pattern: "log/", Description: "Rails log directory", Ecosystem: Ruby}, {Pattern: "tmp/", Description: "Rails tmp directory", Ecosystem: Ruby}, }, PHP: { {Pattern: "vendor/", Description: "Composer vendor directory", Ecosystem: PHP}, {Pattern: ".phpunit*", Description: "PHPUnit config/cache", Ecosystem: PHP}, {Pattern: "*.phpunit.result.cache", Description: "PHPUnit result cache", Ecosystem: PHP}, {Pattern: ".php-cs-fixer*", Description: "PHP CS Fixer config", Ecosystem: PHP}, {Pattern: "storage/logs/", Description: "Laravel/Symfony logs", Ecosystem: PHP}, {Pattern: "bootstrap/cache/", Description: "Laravel bootstrap cache", Ecosystem: PHP}, {Pattern: "var/cache/", Description: "Symfony cache", Ecosystem: PHP}, {Pattern: "var/log/", Description: "Symfony logs", Ecosystem: PHP}, }, Elixir: { {Pattern: "_build/", Description: "Elixir/Mix build artifacts", Ecosystem: Elixir}, {Pattern: "deps/", Description: "Mix dependencies", Ecosystem: Elixir}, {Pattern: ".elixir_ls/", Description: "ElixirLS language server data", Ecosystem: Elixir}, {Pattern: "priv/static/", Description: "Phoenix compiled static assets (if pre-built)", Ecosystem: Elixir}, }, DotNet: { {Pattern: "bin/", Description: ".NET build output", Ecosystem: DotNet}, {Pattern: "obj/", Description: ".NET intermediate build files", Ecosystem: DotNet}, {Pattern: "*.nupkg", Description: "NuGet packages", Ecosystem: DotNet}, {Pattern: "*.snupkg", Description: "NuGet symbol packages", Ecosystem: DotNet}, {Pattern: ".vs/", Description: "Visual Studio metadata", Ecosystem: DotNet}, {Pattern: "packages/", Description: "NuGet packages directory (legacy)", Ecosystem: DotNet}, {Pattern: "TestResults/", Description: ".NET test results", Ecosystem: DotNet}, }, }
EcosystemBloatPatterns maps each ecosystem to its specific bloat patterns.
var UniversalBloatPatterns = []BloatPattern{
{Pattern: ".git/", Description: "Git history — not needed in images"},
{Pattern: ".git", Description: "Git directory"},
{Pattern: ".gitignore", Description: "Git ignore file"},
{Pattern: ".gitattributes", Description: "Git attributes file"},
{Pattern: ".github/", Description: "GitHub metadata"},
{Pattern: ".vscode/", Description: "VS Code settings"},
{Pattern: ".idea/", Description: "JetBrains IDE settings"},
{Pattern: ".editorconfig", Description: "Editor config"},
{Pattern: "*.md", Description: "Markdown docs"},
{Pattern: "*.txt", Description: "Text files (README, CHANGELOG, etc.)"},
{Pattern: "LICENSE*", Description: "License files"},
{Pattern: "CHANGELOG*", Description: "Changelog files"},
{Pattern: "CONTRIBUTING*", Description: "Contribution guidelines"},
{Pattern: "docs/", Description: "Documentation directory"},
{Pattern: "doc/", Description: "Documentation directory"},
{Pattern: "test/", Description: "Test directory"},
{Pattern: "tests/", Description: "Test directory"},
{Pattern: "spec/", Description: "Spec/test directory"},
{Pattern: "__tests__/", Description: "Jest test directory"},
{Pattern: "*.test.*", Description: "Test files"},
{Pattern: "*.spec.*", Description: "Spec files"},
{Pattern: "coverage/", Description: "Coverage reports"},
{Pattern: ".nyc_output/", Description: "NYC coverage data"},
{Pattern: ".env", Description: "Environment file with secrets"},
{Pattern: ".env.*", Description: "Environment files"},
{Pattern: "docker-compose*.yml", Description: "Docker Compose files"},
{Pattern: "docker-compose*.yaml", Description: "Docker Compose files"},
{Pattern: "Makefile", Description: "Build automation"},
{Pattern: "Dockerfile*", Description: "Dockerfiles (already used for build)"},
{Pattern: ".dockerignore", Description: "Docker ignore file"},
{Pattern: "*.log", Description: "Log files"},
{Pattern: "tmp/", Description: "Temporary files"},
{Pattern: ".tmp/", Description: "Temporary files"},
{Pattern: ".cache/", Description: "Generic cache directory"},
{Pattern: ".DS_Store", Description: "macOS metadata file"},
{Pattern: "Thumbs.db", Description: "Windows thumbnail cache"},
{Pattern: "*.swp", Description: "Vim swap files"},
{Pattern: "*.swo", Description: "Vim swap files"},
{Pattern: "*.bak", Description: "Backup files"},
}
UniversalBloatPatterns are patterns that are bloat in any ecosystem.
Functions ¶
This section is empty.
Types ¶
type BloatPattern ¶
type BloatPattern struct {
Pattern string // glob or path prefix
Description string // human-readable explanation
Ecosystem Type // which ecosystem this belongs to (empty = universal)
}
BloatPattern defines a file or directory pattern that is typically bloat.
func GetBloatPatterns ¶
func GetBloatPatterns(ecosystems *DetectResult) []BloatPattern
GetBloatPatterns returns all bloat patterns for the given ecosystems, combined with universal patterns.
func MatchesBloatPattern ¶
func MatchesBloatPattern(path string, patterns []BloatPattern) (bool, *BloatPattern)
MatchesBloatPattern checks if a file path matches any of the given bloat patterns.
type DetectResult ¶
type DetectResult struct {
Ecosystems map[Type][]string // ecosystem -> labels (e.g., NodeJS -> ["npm", "yarn"])
}
DetectResult holds the detected ecosystems and their labels.
func DetectFromEcosystemFlag ¶
func DetectFromEcosystemFlag(flag string) *DetectResult
DetectFromEcosystemFlag parses a comma-separated ecosystem flag value like "go,node,php" into DetectResult.
func DetectFromFiles ¶
func DetectFromFiles(files []string) *DetectResult
DetectFromFiles takes a list of file paths (relative to image root) and returns which ecosystems are present.
func (*DetectResult) HasEcosystem ¶
func (d *DetectResult) HasEcosystem(t Type) bool
HasEcosystem checks if a specific ecosystem was detected.
func (*DetectResult) String ¶
func (d *DetectResult) String() string
String returns a human-readable, deterministically ordered summary like "Node.js (npm), Python (pip)".
func (*DetectResult) Types ¶
func (d *DetectResult) Types() []Type
Types returns just the ecosystem types detected, sorted for stability.