# ============================================================================== # .dockerignore - Docker 构建上下文优化 # 排除不必要的文件,减小构建上下文大小,加速构建过程 # ============================================================================== # Git 版本控制 # ------------------------------------------------------------------------------ .git/ .gitignore .gitattributes .gitmodules .github/ .gitlab-ci.yml Jenkinsfile .git/ # Python 相关 # ------------------------------------------------------------------------------ # 字节码文件 __pycache__/ *.py[cod] *$py.class *.so # 分发 / 打包 .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # 虚拟环境 .venv/ venv/ ENV/ env/ ENV/ # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre 类型检查器 .pyre/ # pytype 静态类型分析器 .pytype/ # Cython 调试文件 cython_debug/ # PyCharm .idea/ # 测试覆盖率 htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py,cover .hypothesis/ .pytest_cache/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # Node.js / Frontend 相关 # ------------------------------------------------------------------------------ # 依赖和包 node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* pnpm-debug.log* lerna-debug.log* .pnpm-debug.log* # 构建输出 dist/ build/ dist-ssr/ *.local # 编辑器目录和文件 .vscode/ !.vscode/extensions.json .idea/ .DS_Store *.suo *.ntvs* *.njsproj *.sln *.sw? # 测试 .nyc_output coverage/ *.lcov # Storybook 构建输出 storybook-static/ # Nuxt.js / .nuxt .nuxt .output # Vuepress 构建输出 .vuepress/dist # Serverless 目录 .serverless/ # FuseBox 缓存 .fusebox/ # DynamoDB Local 文件 .dynamodb/ # TernJS 端口文件 .tern-port # Docker 相关 # ------------------------------------------------------------------------------ # Docker Compose 文件 (通过 docker-compose 命令使用,不需复制) # docker-compose.yml # docker-compose.override.yml # docker-compose.*.yml # Dockerfile (使用上下文中的 Dockerfile,不需复制) # Dockerfile # Dockerfile.* # dockerignore # .dockerignore # 环境和配置文件 # ------------------------------------------------------------------------------ .env .env.* !.env.example !.env.external.example .env.local .env.development.local .env.test.local .env.production.local # 私钥和证书 *.pem *.key *.crt *.csr *.p12 *.pfx # 数据库 *.db *.sqlite *.sqlite3 # 日志文件 *.log logs/ log/ *.log.* # 文档和说明 # ------------------------------------------------------------------------------ *.md README* CHANGELOG* HISTORY* docs/ doc/ documentation/ # 手册和帮助 man/ *.1 *.2 *.3 # 文本文件 *.txt *.rtf # IDE 和编辑器 # ------------------------------------------------------------------------------ .vscode/ .idea/ *.swp *.swo *~ .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes ehthumbs.db Thumbs.db # Emacs *~ \#*\# /.emacs.desktop /.emacs.desktop.lock *.elc auto-save-list tramp .\#* # Vim [._]*.s[a-v][a-z] [._]*.sw[a-p] [._]s[a-rt-v][a-z] [._]ss[a-gi-z] [._]sw[a-p] Session.vim Sessionx.vim .netrwhist *~ tags [._]*.un~ # 操作系统 # ------------------------------------------------------------------------------ # Windows Thumbs.db ehthumbs.db Desktop.ini $RECYCLE.BIN/ *.cab *.msi *.msm *.msp *.lnk # macOS .AppleDouble .LSOverride Icon ._* .DocumentRevisions-V100 .fseventsd .Spotlight-V100 .TemporaryItems .Trashes .VolumeIcon.icns .com.apple.timemachine.donotpresent .AppleDB .AppleDesktop Network Trash Folder Temporary Items .apdisk # Linux *~ .fuse_hidden* .directory .Trash-* .nfs* # 临时文件和备份 # ------------------------------------------------------------------------------ *.tmp *.temp *.bak *.backup *.orig *.save *.swp *.swo *~ # 临时目录 tmp/ temp/ .tmp/ .cache/ .parcel-cache/ # 备份文件 *.bak *.bak-* *.old *.orig *.rej *.diff # 压缩包 *.tar *.tar.gz *.zip *.rar *.7z # 开发和调试工具 # ------------------------------------------------------------------------------ # Sentry CLI (Sentry Config) .sentryclirc # ESLint .eslintcache # Prettier .prettierignore # Stylelint .stylelintignore # Terraform *.tfstate *.tfstate.* .terraform/ .terraform.lock.hcl # Kubernetes kube-config.yml # 性能和分析工具 # ------------------------------------------------------------------------------ # Webpack .webpack/ # Rollup .rollup.cache/ # Parcel .parcel-cache/ # Vercel .vercel # Turborepo .turbo/ # 部署和运维 # ------------------------------------------------------------------------------ # 部署脚本 deploy*.sh deploy-offline.sh push-offline.sh *.deployment # CI/CD .github/ .gitlab-ci.yml .travis.yml .circleci/ # Ansible ansible/ *.yml !docker-compose.yml # Terraform *.tf *.tfvars !.env.example # Kubernetes *.yaml *.yml !docker-compose.yml !*.example.yml # 数据库迁移和种子数据 # ------------------------------------------------------------------------------ # 迁移文件 migrations/ alembic/versions/ # 种子数据 seeds/ seed_data/ # 备份文件 backups/ *.dump *.sql # 监控和指标 # ------------------------------------------------------------------------------ # Prometheus prometheus.yml # Grafana grafana.db # 其他监控工具 metrics/ # 杂项 # ------------------------------------------------------------------------------ # 字体文件 (如果不需要) *.ttf *.eot *.woff *.woff2 # 音频文件 *.mp3 *.wav *.flac # 视频文件 *.mp4 *.avi *.mov # 图像文件 (如果不需要) *.psd *.sketch *.fig # 项目特定文件 .version .quick_start.md # 不需要的目录 tests/ test/ spec/ specs/ *.test.js *.spec.js # ============================================================================== # 优化建议: # ------------------------------------------------------------------------------ # 1. 将 .dockerignore 放在项目根目录 # 2. 定期检查构建上下文大小: docker context ls # 3. 构建时排除不必要文件可显著提升速度 # 4. 大型二进制文件 (>100MB) 应通过卷挂载而非复制 # 5. 敏感信息 (.env, *.key) 绝对不能包含在构建上下文中 # ==============================================================================