Agent Skillsnixopus/nixopus › dockerignore-generation

dockerignore-generation

GitHub

根据项目语言自动生成.dockerignore文件,排除无关文件和敏感信息,优化Docker构建上下文并防止密钥泄露。

api/skills/dockerignore-generation/SKILL.md nixopus/nixopus

Trigger Scenarios

生成.dockerignore文件 优化Docker构建速度 防止构建上下文过大 避免密钥泄露到镜像中

Install

npx skills add nixopus/nixopus --skill dockerignore-generation -g -y
More Options

Non-standard path

npx skills add https://github.com/nixopus/nixopus/tree/master/api/skills/dockerignore-generation -g -y

Use without installing

npx skills use nixopus/nixopus@dockerignore-generation

指定 Agent (Claude Code)

npx skills add nixopus/nixopus --skill dockerignore-generation -a claude-code -g -y

安装 repo 全部 skill

npx skills add nixopus/nixopus --all -g -y

预览 repo 内 skill

npx skills add nixopus/nixopus --list

SKILL.md

Frontmatter
{
    "name": "dockerignore-generation",
    "metadata": {
        "version": "1.0"
    },
    "description": "Generate ecosystem-specific .dockerignore files to reduce build context size and prevent secret leaks. Use when no .dockerignore exists, when the build context is large, or when secrets may be leaking into images."
}

.dockerignore Generation

Why It Matters

Without a .dockerignore:

  • Build context includes node_modules (hundreds of MB), .git history, and local env files
  • Secrets in .env files get copied into the image and are extractable
  • Build is slow because Docker sends the entire directory to the daemon

Base Template (all ecosystems)

Every .dockerignore should include:

.git
.gitignore
.env
.env.*
!.env.example
!.env.sample
*.md
!README.md
LICENSE
docker-compose*.yml
.dockerignore
Dockerfile
.vscode
.idea
.cursor

Ecosystem-Specific Entries

Node.js

node_modules
.next
.nuxt
.output
dist
build
.cache
coverage
.nyc_output
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.turbo
.vercel
.netlify
storybook-static

Python

__pycache__
*.pyc
*.pyo
*.egg-info
.eggs
.venv
venv
env
.tox
.pytest_cache
.mypy_cache
.ruff_cache
htmlcov
*.cover

Go

vendor/
*.test
*.out
bin/
tmp/

Rust

target/
*.rs.bk

Java

target/
build/
.gradle/
*.class
*.jar
!*.jar  # if copying JARs intentionally, remove this line
.settings/
.classpath
.project

Ruby

vendor/bundle
.bundle
log/
tmp/
coverage/
spec/reports

PHP

vendor/
storage/logs/
storage/framework/cache/
storage/framework/sessions/
storage/framework/views/
bootstrap/cache/

Elixir

_build/
deps/
.elixir_ls/
cover/

.NET

bin/
obj/
*.user
*.suo
packages/

Generation Logic

  1. Start with the base template
  2. Detect ecosystem from the project (check for package.json, go.mod, requirements.txt, etc.)
  3. Append the matching ecosystem entries
  4. If test/ or tests/ or __tests__/ exists: add test directories
  5. If .github/ exists: add .github/
  6. Write to .dockerignore at the project root

Gotchas

  • !.env.example negates the .env.* exclusion — keep example env files so Dockerfile can reference them
  • Monorepos: .dockerignore is relative to the build context root, not the Dockerfile location
  • Docker Compose build.context changes what .dockerignore applies to — if context is ., the root .dockerignore applies
  • Don't ignore prisma/ if Prisma is used — prisma/schema.prisma is needed for postinstall
  • Don't ignore lockfiles (package-lock.json, yarn.lock, etc.) — they're essential for reproducible builds

Related Skills

  • pre-deploy-checklist — Checks for .dockerignore existence and flags missing ones
  • dockerfile-generation — Generate .dockerignore alongside the Dockerfile

Version History

  • cf05d97 Current 2026-08-20 14:51

Same Skill Collection

api/skills/api-catalog/SKILL.md
api/skills/caddyfile-generation/SKILL.md
api/skills/compose-setup/SKILL.md
api/skills/container-resource-tuning/SKILL.md
api/skills/cpp-deploy/SKILL.md
api/skills/database-migration/SKILL.md
api/skills/deno-deploy/SKILL.md
api/skills/deploy-delegation/SKILL.md
api/skills/deploy-flow/SKILL.md
api/skills/deployment-analysis/SKILL.md
api/skills/diagnostic-workflow/SKILL.md
api/skills/dockerfile-generation/SKILL.md
api/skills/domain-attachment/SKILL.md
api/skills/domain-tls-routing/SKILL.md
api/skills/dotnet-deploy/SKILL.md
api/skills/elixir-deploy/SKILL.md
api/skills/failure-diagnosis/SKILL.md
api/skills/github-onboarding/SKILL.md
api/skills/github-workflow/SKILL.md
api/skills/gleam-deploy/SKILL.md
api/skills/go-deploy/SKILL.md
api/skills/incident-response/SKILL.md
api/skills/java-deploy/SKILL.md
api/skills/machine-ops/SKILL.md
api/skills/mcp-integrations/SKILL.md
api/skills/monorepo-strategy/SKILL.md
api/skills/nixopus-docs/SKILL.md
api/skills/node-deploy/SKILL.md
api/skills/onboarding/SKILL.md
api/skills/php-deploy/SKILL.md
api/skills/post-deploy-verification/SKILL.md
api/skills/pre-deploy-checklist/SKILL.md
api/skills/python-deploy/SKILL.md
api/skills/rollback-strategy/SKILL.md
api/skills/ruby-deploy/SKILL.md
api/skills/rust-deploy/SKILL.md
api/skills/self-heal/SKILL.md
api/skills/shell-deploy/SKILL.md
api/skills/static-deploy/SKILL.md

Metadata

Files
0
Version
cf05d97
Hash
e6373b7b
Indexed
2026-08-20 14:51

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-30 04:06
浙ICP备14020137号-1 $Гость$