多容器配置

Universal

ln-731-docker-generator

by levnikolaevich

按前端、.NET 或 Python 技术栈自动生成 Dockerfile、docker-compose、.dockerignore 和 nginx 配置,适合多容器项目初始化时搭建本地与生产一致的开发环境。

为多容器开发自动生成 Docker 与 docker-compose 配置,省去手写编排的繁琐,搭环境更快更稳。

405DevOps未扫描2026年3月5日

安装

claude skill add --url github.com/levnikolaevich/claude-code-skills/tree/master/ln-731-docker-generator

文档

Paths: File paths (shared/, references/, ../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.

ln-731-docker-generator

Type: L3 Worker Category: 7XX Project Bootstrap Parent: ln-730-devops-setup

Generates production-ready Docker configuration for containerized development.


Purpose & Scope

Creates Docker infrastructure for local development and production:

  • Does: Generate Dockerfiles, docker-compose, .dockerignore, nginx config
  • Does NOT: Build images, start containers, manage deployments

Inputs

InputSourceDescription
Stack Typeln-730 coordinatorfrontend, backend-dotnet, backend-python
VersionsAuto-detectedNode.js, .NET, Python versions
Project NameDirectory nameUsed for container naming
PortsDefaults or detectedFrontend: 3000, Backend: 5000/8000, DB: 5432

Outputs

FilePurposeTemplate
Dockerfile.frontendFrontend build & servedockerfile_frontend.template
Dockerfile.backendBackend build & rundockerfile_backend_dotnet.template or dockerfile_backend_python.template
docker-compose.ymlService orchestrationdocker_compose.template
.dockerignoreBuild context exclusionsdockerignore.template
nginx.confFrontend proxy confignginx.template

Workflow

Phase 1: Input Validation

Validate received configuration from coordinator:

  • Check stack type is supported (frontend, backend-dotnet, backend-python)
  • Verify versions are valid (Node 18+, .NET 8+, Python 3.10+)
  • Confirm project directory exists

Output: Validated configuration or error

Phase 2: Template Selection

Select appropriate templates based on stack:

StackTemplates Used
Frontend onlydockerfile_frontend, nginx, dockerignore
Backend .NETdockerfile_backend_dotnet, docker_compose, dockerignore
Backend Pythondockerfile_backend_python, docker_compose, dockerignore
Full stack .NETAll of the above (dotnet variant)
Full stack PythonAll of the above (python variant)

Phase 3: Variable Substitution

Replace template variables with detected values:

VariableSourceExample
{{NODE_VERSION}}package.json engines or default22
{{DOTNET_VERSION}}*.csproj TargetFramework9.0
{{PYTHON_VERSION}}pyproject.toml or default3.12
{{PROJECT_NAME}}Directory namemy-app
{{DLL_NAME}}*.csproj AssemblyNameMyApp.Api.dll
{{FRONTEND_PORT}}Default or detected3000
{{BACKEND_PORT}}Stack-dependent5000 (.NET), 8000 (Python)
{{BACKEND_HOST}}Service namebackend
{{CMD}}Framework-dependent["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] (FastAPI) or ["gunicorn", "--bind", "0.0.0.0:8000", "{{PROJECT_NAME}}.wsgi:application"] (Django)

Phase 4: File Generation

Generate files from templates:

  1. Check if file already exists (warn before overwrite)
  2. Apply variable substitution
  3. Write file to appropriate location
  4. Validate syntax where possible

File Locations:

  • Dockerfile.frontend -> src/frontend/Dockerfile
  • Dockerfile.backend -> project root
  • docker-compose.yml -> project root
  • .dockerignore -> project root
  • nginx.conf -> src/frontend/nginx.conf

Supported Stacks

Frontend: React/Vite + Nginx

Requirements:

  • package.json with build script
  • Vite or CRA configuration

Generated:

  • Multi-stage Dockerfile (builder + nginx)
  • Nginx config with SPA routing and API proxy

Backend: .NET 8/9

Requirements:

  • *.sln file in root
  • *.csproj with TargetFramework

Generated:

  • Multi-stage Dockerfile (SDK build + ASP.NET runtime)
  • Health check endpoint configuration

Backend: Python (FastAPI/Django)

Requirements:

  • requirements.txt or pyproject.toml

Generated:

  • Multi-stage Dockerfile (builder + slim runtime)
  • uvicorn (FastAPI) or gunicorn (Django) entrypoint

Security & Performance Best Practices

All generated files follow these guidelines:

PracticeImplementation
Non-root userCreate and use appuser (UID 1001)
Minimal imagesAlpine/slim variants
Multi-stage buildsExclude build tools from runtime
No secretsUse environment variables, not hardcoded
Health checksBuilt-in HEALTHCHECK instructions (wget/curl)
Specific versionsPin base image versions (e.g., nginx:1.27-alpine)
Non-interactive modeARG DEBIAN_FRONTEND=noninteractive
Layer cachingCopy dependency files first, source code last
BuildKit cacheUse --mount=type=cache for pip
Python optimizationPYTHONDONTWRITEBYTECODE=1, PYTHONUNBUFFERED=1

Quality Criteria

Generated files must meet:

  • docker-compose config validates without errors
  • All base images use specific versions (not latest)
  • Non-root user configured in all Dockerfiles
  • Health checks present for all services
  • .dockerignore excludes all sensitive files
  • No hardcoded secrets or passwords

Critical Notes

  1. Version Detection: Use detected versions from coordinator, not hardcoded defaults.
  2. Idempotent: Check file existence before writing. Warn if overwriting.
  3. Template-based: All generation uses templates from references/. Do NOT hardcode file contents.
  4. Security First: Every generated file must follow security best practices.

Reference Files

FilePurpose
dockerfile_frontend.templateReact/Vite multi-stage Dockerfile
dockerfile_backend_dotnet.template.NET multi-stage Dockerfile
dockerfile_backend_python.templatePython multi-stage Dockerfile
docker_compose.templatedocker-compose.yml template
dockerignore.template.dockerignore template
nginx.templateNginx configuration

Version: 1.2.0 Last Updated: 2026-01-21

相关 Skills

可观测性设计

by alirezarezvani

Universal
热门

面向生产系统规划可落地的可观测性体系,串起指标、日志、链路追踪与 SLI/SLO、错误预算、告警和仪表盘设计,适合搭建监控平台与优化故障响应。

把监控、日志、链路追踪串起来,帮助团队从设计阶段构建可观测性,排障更快、系统演进更稳。

DevOps
未扫描11.5k

AWS架构师

by alirezarezvani

Universal
热门

面向初创团队规划 AWS 架构,覆盖 Serverless、ECS、Aurora 等方案,可生成 CloudFormation 模板,兼顾成本优化、CI/CD 搭建与迁移上云。

特别适合创业团队,用无服务器模式和 IaC 模板快速搭好 AWS 架构,连成本优化、CI/CD 与迁移路径都能一并规划。

DevOps
未扫描11.5k

环境密钥管理

by alirezarezvani

Universal
热门

统一梳理dev/staging/prod的.env和密钥流程,自动生成.env.example、校验必填变量、扫描Git历史泄漏,并联动Vault、AWS SSM、1Password、Doppler完成轮换。

统一管理环境变量、密钥与配置,减少泄露和部署混乱,安全治理与团队协作一起做好,DevOps 场景很省心。

DevOps
未扫描11.5k

相关 MCP 服务

kubefwd

编辑精选

by txn2

热门

kubefwd 是让 AI 帮你批量转发 Kubernetes 服务到本地的开发神器。

微服务开发者最头疼的本地调试问题,它一键搞定——自动分配 IP 避免端口冲突,还能用自然语言查询状态。但依赖 AI 工作流,纯命令行爱好者可能觉得不够直接。

DevOps
4.1k

Cloudflare

编辑精选

by Cloudflare

热门

Cloudflare MCP Server 是让你用自然语言管理 Workers、KV 和 R2 等云资源的工具。

这个工具解决了开发者频繁切换控制台和文档的痛点,特别适合那些在 Cloudflare 上部署无服务器应用、需要快速调试或管理配置的团队。不过,由于它依赖多个子服务器,初次设置可能有点繁琐,建议先从 Workers Bindings 这类核心功能入手。

DevOps
3.6k

Terraform

编辑精选

by hashicorp

Terraform MCP Server 是让 AI 助手直接操作 Terraform Registry 和 HCP Terraform 的桥梁。

如果你经常在 Terraform 里翻文档找模块配置,这个服务器能省不少时间——直接问 Claude 就能生成准确的代码片段。最适合管理多云基础设施的团队,但注意它目前只适合本地使用,别在生产环境里暴露 HTTP 端点。

DevOps
1.3k

评论