ln-731-docker-generator by levnikolaevich/claude-code-skills
npx skills add https://github.com/levnikolaevich/claude-code-skills --skill ln-731-docker-generator路径说明: 文件路径(
shared/、references/、../ln-*)是相对于技能仓库根目录的。如果在当前工作目录下未找到,请定位此 SKILL.md 文件所在的目录,然后向上返回一级以找到仓库根目录。如果缺少shared/目录,请通过 WebFetch 从https://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/skills/{path}获取文件。
类型: L3 Worker 类别: 7XX 项目引导
为容器化开发生成生产就绪的 Docker 配置。
为本地开发和生产环境创建 Docker 基础设施:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 输入 | 来源 | 描述 |
|---|---|---|
| 技术栈类型 | ln-730 协调器 | frontend, backend-dotnet, backend-python |
| 版本 | 自动检测 | Node.js, .NET, Python 版本 |
| 项目名称 | 目录名称 | 用于容器命名 |
| 端口 | 默认值或检测值 | 前端:3000,后端:5000/8000,数据库:5432 |
| 文件 | 用途 | 模板 |
|---|---|---|
Dockerfile.frontend | 前端构建与服务 | dockerfile_frontend.template |
Dockerfile.backend | 后端构建与运行 | dockerfile_backend_dotnet.template 或 dockerfile_backend_python.template |
docker-compose.yml | 服务编排 | docker_compose.template |
.dockerignore | 构建上下文排除项 | dockerignore.template |
nginx.conf | 前端代理配置 | nginx.template |
验证从协调器接收到的配置:
输出:验证通过的配置或错误信息
根据技术栈选择合适的模板:
| 技术栈 | 使用的模板 |
|---|---|
| 仅前端 | dockerfile_frontend, nginx, dockerignore |
| 后端 .NET | dockerfile_backend_dotnet, docker_compose, dockerignore |
| 后端 Python | dockerfile_backend_python, docker_compose, dockerignore |
| 全栈 .NET | 以上所有(dotnet 变体) |
| 全栈 Python | 以上所有(python 变体) |
将模板变量替换为检测到的值:
| 变量 | 来源 | 示例 |
|---|---|---|
{{NODE_VERSION}} | package.json 中的 engines 或默认值 | 22 |
{{DOTNET_VERSION}} | *.csproj 中的 TargetFramework | 9.0 |
{{PYTHON_VERSION}} | pyproject.toml 或默认值 | 3.12 |
{{PROJECT_NAME}} | 目录名称 | my-app |
{{DLL_NAME}} | *.csproj 中的 AssemblyName | MyApp.Api.dll |
{{FRONTEND_PORT}} | 默认值或检测值 | 3000 |
{{BACKEND_PORT}} | 依赖于技术栈 | 5000 (.NET), 8000 (Python) |
{{BACKEND_HOST}} | 服务名称 | backend |
{{CMD}} | 依赖于框架 | ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] (FastAPI) 或 ["gunicorn", "--bind", "0.0.0.0:8000", "{{PROJECT_NAME}}.wsgi:application"] (Django) |
根据模板生成文件:
文件位置:
Dockerfile.frontend -> src/frontend/DockerfileDockerfile.backend -> 项目根目录docker-compose.yml -> 项目根目录.dockerignore -> 项目根目录nginx.conf -> src/frontend/nginx.conf要求:
生成内容:
要求:
生成内容:
要求:
生成内容:
所有生成的文件都遵循以下准则:
| 实践 | 实现 |
|---|---|
| 非 root 用户 | 创建并使用 appuser (UID 1001) |
| 最小化镜像 | 使用 Alpine/slim 变体 |
| 多阶段构建 | 从运行时镜像中排除构建工具 |
| 不包含密钥 | 使用环境变量,而非硬编码 |
| 健康检查 | 内置 HEALTHCHECK 指令(wget/curl) |
| 指定版本 | 固定基础镜像版本(例如 nginx:1.27-alpine) |
| 非交互模式 | ARG DEBIAN_FRONTEND=noninteractive |
| 层缓存 | 先复制依赖文件,最后复制源代码 |
| BuildKit 缓存 | 对 pip 使用 --mount=type=cache |
| Python 优化 | PYTHONDONTWRITEBYTECODE=1, PYTHONUNBUFFERED=1 |
生成的文件必须满足:
docker-compose config 验证无误latest)| 文件 | 用途 |
|---|---|
| dockerfile_frontend.template | React/Vite 多阶段 Dockerfile |
| dockerfile_backend_dotnet.template | .NET 多阶段 Dockerfile |
| dockerfile_backend_python.template | Python 多阶段 Dockerfile |
| docker_compose.template | docker-compose.yml 模板 |
| dockerignore.template | .dockerignore 模板 |
| nginx.template | Nginx 配置 |
docker-compose config)latest)版本: 1.2.0 最后更新: 2026-01-21
每周安装
149
仓库
GitHub 星标
245
首次出现
2026年1月24日
安全审计
安装于
claude-code136
gemini-cli134
cursor134
opencode134
codex133
github-copilot128
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. Ifshared/is missing, fetch files via WebFetch fromhttps://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/skills/{path}.
Type: L3 Worker Category: 7XX Project Bootstrap
Generates production-ready Docker configuration for containerized development.
Creates Docker infrastructure for local development and production:
| Input | Source | Description |
|---|---|---|
| Stack Type | ln-730 coordinator | frontend, backend-dotnet, backend-python |
| Versions | Auto-detected | Node.js, .NET, Python versions |
| Project Name | Directory name | Used for container naming |
| Ports | Defaults or detected | Frontend: 3000, Backend: 5000/8000, DB: 5432 |
| File | Purpose | Template |
|---|---|---|
Dockerfile.frontend | Frontend build & serve | dockerfile_frontend.template |
Dockerfile.backend | Backend build & run | dockerfile_backend_dotnet.template or dockerfile_backend_python.template |
docker-compose.yml | Service orchestration | docker_compose.template |
Validate received configuration from coordinator:
Output : Validated configuration or error
Select appropriate templates based on stack:
| Stack | Templates Used |
|---|---|
| Frontend only | dockerfile_frontend, nginx, dockerignore |
| Backend .NET | dockerfile_backend_dotnet, docker_compose, dockerignore |
| Backend Python | dockerfile_backend_python, docker_compose, dockerignore |
| Full stack .NET | All of the above (dotnet variant) |
| Full stack Python | All of the above (python variant) |
Replace template variables with detected values:
| Variable | Source | Example |
|---|---|---|
{{NODE_VERSION}} | package.json engines or default | 22 |
{{DOTNET_VERSION}} | *.csproj TargetFramework | 9.0 |
{{PYTHON_VERSION}} | pyproject.toml or default | 3.12 |
{{PROJECT_NAME}} | Directory name | my-app |
{{DLL_NAME}} | *.csproj AssemblyName |
Generate files from templates:
File Locations :
Dockerfile.frontend -> src/frontend/DockerfileDockerfile.backend -> project rootdocker-compose.yml -> project root.dockerignore -> project rootnginx.conf -> src/frontend/nginx.confRequirements :
Generated :
Requirements :
Generated :
Requirements :
Generated :
All generated files follow these guidelines:
| Practice | Implementation |
|---|---|
| Non-root user | Create and use appuser (UID 1001) |
| Minimal images | Alpine/slim variants |
| Multi-stage builds | Exclude build tools from runtime |
| No secrets | Use environment variables, not hardcoded |
| Health checks | Built-in HEALTHCHECK instructions (wget/curl) |
| Specific versions | Pin base image versions (e.g., nginx:1.27-alpine) |
| Non-interactive mode | ARG DEBIAN_FRONTEND=noninteractive |
| Layer caching | Copy dependency files first, source code last |
| BuildKit cache | Use --mount=type=cache for pip |
Generated files must meet:
docker-compose config validates without errorslatest)| File | Purpose |
|---|---|
| dockerfile_frontend.template | React/Vite multi-stage Dockerfile |
| dockerfile_backend_dotnet.template | .NET multi-stage Dockerfile |
| dockerfile_backend_python.template | Python multi-stage Dockerfile |
| docker_compose.template | docker-compose.yml template |
| dockerignore.template | .dockerignore template |
| nginx.template | Nginx configuration |
docker-compose config)latest)Version: 1.2.0 Last Updated: 2026-01-21
Weekly Installs
149
Repository
GitHub Stars
245
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code136
gemini-cli134
cursor134
opencode134
codex133
github-copilot128
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
104,900 周安装
.dockerignore | Build context exclusions | dockerignore.template |
nginx.conf | Frontend proxy config | nginx.template |
| MyApp.Api.dll |
{{FRONTEND_PORT}} | Default or detected | 3000 |
{{BACKEND_PORT}} | Stack-dependent | 5000 (.NET), 8000 (Python) |
{{BACKEND_HOST}} | Service name | backend |
{{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) |
| Python optimization | PYTHONDONTWRITEBYTECODE=1, PYTHONUNBUFFERED=1 |