Loading...
Loading...
Compare original and translation side by side
undefinedundefined
**Adapt configurations based on detection:**
| Detected Docker Memory | Profile | Build Memory | Container Limits |
|-----------------------|---------|--------------|------------------|
| < 4GB | Constrained | 1GB | 256Mi |
| 4-8GB | Minimal | 2GB | 512Mi |
| 8-12GB | Standard | 4GB | 1Gi |
| > 12GB | Extended | 8GB | 2Gi |
**根据检测结果适配配置:**
| 检测到的Docker内存 | 配置文件 | 构建内存 | 容器限制 |
|-----------------------|---------|--------------|------------------|
| < 4GB | 受限模式 | 1GB | 256Mi |
| 4-8GB | 最小模式 | 2GB | 512Mi |
| 8-12GB | 标准模式 | 4GB | 1Gi |
| > 12GB | 扩展模式 | 8GB | 2Gi |docker_memory * 0.6 / container_countdocker_memory * 0.6 / container_countservices:
app:
deploy:
resources:
limits:
memory: 256M
cpus: '0.25'
build:
args:
- BUILDKIT_STEP_LOG_MAX_SIZE=10000000services:
app:
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
reservations:
memory: 256Mservices:
app:
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 512Mservices:
app:
deploy:
resources:
limits:
memory: 256M
cpus: '0.25'
build:
args:
- BUILDKIT_STEP_LOG_MAX_SIZE=10000000services:
app:
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
reservations:
memory: 256Mservices:
app:
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 512Mdocker buildundefineddocker buildundefined
If constrained: use `--memory` flag and warn user about potential build failures.
---
如果处于受限模式:使用`--memory`参数,并警告用户可能出现构建失败。
---output: 'standalone':latestoutput: 'standalone':latest| Source | Gather |
|---|---|
| Codebase | Package files, existing Dockerfile, .env patterns |
| Conversation | Dev vs production target, base image preferences |
| Skill References | Framework patterns, multi-stage builds, security |
| User Guidelines | Registry conventions, naming standards |
| 来源 | 收集内容 |
|---|---|
| 代码库 | 包文件、现有Dockerfile、.env文件模式 |
| 对话记录 | 开发或生产目标、基础镜像偏好 |
| 技能参考 | 框架模式、多阶段构建、安全规范 |
| 用户指南 | 镜像仓库约定、命名标准 |
| Question | When to Ask |
|---|---|
| Target environment | "Building for development or production?" |
| Base image preference | "Standard slim images or enterprise hardened?" |
| Existing Docker files | "Enhance existing Dockerfile or create new?" |
| Registry target | "Local only or pushing to registry?" |
| 问题 | 询问时机 |
|---|---|
| 目标环境 | "是为开发环境还是生产环境构建?" |
| 基础镜像偏好 | "使用标准slim镜像还是企业级加固镜像?" |
| 现有Docker文件 | "是优化现有Dockerfile还是创建新的?" |
| 目标镜像仓库 | "仅本地使用还是推送到镜像仓库?" |
| File Present | Runtime | Package Manager |
|---|---|---|
| Python | pip/uv |
| Node.js | pnpm |
| Node.js | yarn |
| Node.js | npm |
| 存在的文件 | 运行时 | 包管理器 |
|---|---|---|
| Python | pip/uv |
| Node.js | pnpm |
| Node.js | yarn |
| Node.js | npm |
| What | Detect From |
|---|---|
| Python version | |
| Framework | Imports in code ( |
| Package manager | |
| Native deps | Scan requirements: |
| App entrypoint | Find |
| 检测内容 | 检测来源 |
|---|---|
| Python版本 | |
| 框架 | 代码中的导入语句( |
| 包管理器 | |
| 原生依赖 | 扫描requirements文件: |
| 应用入口点 | 查找 |
| What | Detect From |
|---|---|
| Node version | |
| Framework | |
| Package manager | |
| Output type | Next.js: check |
| 检测内容 | 检测来源 |
|---|---|
| Node版本 | |
| 框架 | |
| 包管理器 | |
| 输出类型 | Next.js:检查 |
| Issue | Action |
|---|---|
Next.js missing | Add it to next.config.js |
| No health endpoint found | Create |
| Using uv but no uv.lock | Run |
| pyproject.toml but no build system | Use |
| 问题 | 操作 |
|---|---|
Next.js缺失 | 添加到next.config.js |
| 未找到健康检查端点 | 创建 |
| 使用uv但无uv.lock | 先运行 |
| 存在pyproject.toml但无构建系统 | 使用 |
1. SCAN PROJECT
- Detect runtime, framework, version, entrypoint
- Find dependency files, native deps
- Locate existing Docker files (don't blindly overwrite)
↓
2. ANALYZE ENVIRONMENT
- Scan all .env* files
- Classify: SECRET (never bake) / BUILD_ARG / RUNTIME
- Flag security issues
↓
3. FIX CONFIGURATION
- Add Next.js `output: 'standalone'` if missing
- Create health endpoints if missing
- Generate .env.example with safe placeholders
↓
4. GENERATE FILES
- Dockerfile (customized CMD, paths, build deps)
- .dockerignore (excludes .env, secrets)
- compose.yaml (with security defaults)
↓
5. VALIDATE & TEST
- docker build --target dev -t app:dev .
- docker build --target production -t app:prod .
- Test health endpoints
- Verify non-root user
- Report image size
↓
6. DELIVER WITH CONTEXT
- All files with explanations
- Security scan command
- Any warnings about secrets
- Rollback instructions if replacing existing1. 扫描项目
- 检测运行时、框架、版本、入口点
- 查找依赖文件、原生依赖
- 定位现有Docker文件(不盲目覆盖)
↓
2. 分析环境
- 扫描所有.env*文件
- 分类:敏感信息(绝不嵌入)/ 构建参数 / 运行时配置
- 标记安全问题
↓
3. 修复配置
- 如果缺失则为Next.js添加`output: 'standalone'`
- 如果缺失则创建健康检查端点
- 生成包含安全占位符的.env.example
↓
4. 生成文件
- Dockerfile(定制化CMD、路径、构建依赖)
- .dockerignore(排除.env、敏感信息)
- compose.yaml(带有安全默认配置)
↓
5. 验证与测试
- docker build --target dev -t app:dev .
- docker build --target production -t app:prod .
- 测试健康检查端点
- 验证非root用户
- 报告镜像大小
↓
6. 附带上下文交付
- 所有文件及说明
- 安全扫描命令
- 关于敏感信息的警告
- 替换现有文件时的回滚说明| Choice | When to Use | Tradeoffs |
|---|---|---|
Slim | General production (default) | Works everywhere, no auth |
DHI | SOC2/HIPAA, enterprise | Requires |
Alpine | Smallest size | musl issues with native deps |
| 选择 | 使用场景 | 权衡 |
|---|---|---|
Slim | 通用生产环境(默认) | 可在所有环境使用,无需认证 |
DHI | SOC2/HIPAA合规、企业环境 | 需要 |
Alpine | 最小镜像体积 | 原生依赖存在musl兼容性问题 |
deps/base → Install dependencies (cached layer)
↓
builder → Build/compile application
↓
dev → Hot-reload, volume mounts (--target dev)
↓
production → Minimal DHI runtime (--target production)deps/base → 安装依赖(缓存层)
↓
builder → 构建/编译应用
↓
dev → 热重载、卷挂载(--target dev)
↓
production → 最小化DHI运行时(--target production)docker build --target dev -t myapp:dev .
docker build --target production -t myapp:prod .docker build --target dev -t myapp:dev .
docker build --target production -t myapp:prod .| Framework | Development | Production |
|---|---|---|
| FastAPI | | |
| Flask | | |
| Django | | |
| 框架 | 开发环境 | 生产环境 |
|---|---|---|
| FastAPI | | |
| Flask | | |
| Django | | |
RUN \
uv pip install -r requirements.txtRUN \
uv pip install -r requirements.txt@asynccontextmanager
async def lifespan(app: FastAPI):
yield # startup
# shutdown logic here@asynccontextmanager
async def lifespan(app: FastAPI):
yield # 启动
# 此处添加关闭逻辑| Framework | Build | Output |
|---|---|---|
| Next.js | | |
| Express | | |
| NestJS | | |
| 框架 | 构建命令 | 输出目录 |
|---|---|---|
| Next.js | | |
| Express | | |
| NestJS | | |
undefinedundefinedundefinedundefinedprocess.on('SIGTERM', () => {
server.close(() => process.exit(0));
});process.on('SIGTERM', () => {
server.close(() => process.exit(0));
});.env.git.env.git| File | Purpose |
|---|---|
| Multi-stage, multi-target build |
| Exclude sensitive/unnecessary files |
| Local development stack |
| Framework-specific health checks |
| 文件 | 用途 |
|---|---|
| 多阶段、多目标构建文件 |
| 排除敏感/不必要文件 |
| 本地开发栈配置 |
| 框架专属健康检查 |
| File | Purpose |
|---|---|
| CRITICAL: Secret detection, .env classification |
| CRITICAL: Validation before delivery |
| 文件 | 用途 |
|---|---|
| 关键:敏感信息检测、.env文件分类 |
| 关键:交付前验证清单 |
| File | When to Read |
|---|---|
| FastAPI: uvicorn, lifespan |
| Flask: gunicorn, blueprints |
| Django: gunicorn, middleware |
| Detect psycopg2, cryptography, etc. |
| Next.js: standalone, ISR |
| npm/yarn/pnpm caching |
| 文件 | 阅读时机 |
|---|---|
| FastAPI:uvicorn、生命周期 |
| Flask:gunicorn、蓝图 |
| Django:gunicorn、中间件 |
| 检测psycopg2、cryptography等原生依赖 |
| Next.js:standalone、增量静态再生 |
| npm/yarn/pnpm缓存 |
| File | When to Read |
|---|---|
| If user needs enterprise security (DHI) |
| Complex build patterns |
| 文件 | 阅读时机 |
|---|---|
| 如果用户需要企业级安全(DHI) |
| 复杂构建模式 |
templates/src.app.main:appundefinedtemplates/src.app.main:appundefinedundefinedundefined