DevOps Dockerfile-prompti: pip-only, ei poetryä/condaa
Malli generoi poetry.lock-riippuvaisen Dockerfilen. Nyt prompti kertoo tarkan riippuvuuksien asennustavan (pyproject.toml/requirements.txt/pip) ja antaa valmiin CMD-rivin. Yksivaiheinen build riittää Pythonille. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2212,14 +2212,22 @@ ${Object.entries(generatedFiles).map(([n, c]) => `--- ${n} ---\n${c}`).join('\n\
|
|||||||
const step6 = step5 + 1;
|
const step6 = step5 + 1;
|
||||||
termLog(`\n<span style="color:#d29922;font-weight:bold">[${step6}] DevOps</span> — Dockerfile`);
|
termLog(`\n<span style="color:#d29922;font-weight:bold">[${step6}] DevOps</span> — Dockerfile`);
|
||||||
pipelineStep('tester', 'Dockerfile', 'active', 'Dockerfile');
|
pipelineStep('tester', 'Dockerfile', 'active', 'Dockerfile');
|
||||||
const dockerPrompt = `Write a Dockerfile for this project. Use multi-stage build:
|
const mainFile = Object.keys(generatedFiles).find(f => f.includes('main') || f.includes('app')) || Object.keys(generatedFiles)[0];
|
||||||
- Stage 1 (builder): install dependencies
|
const hasPyproject = Object.keys(generatedFiles).some(f => f === 'pyproject.toml');
|
||||||
- Stage 2 (runtime): copy only what's needed, minimal image
|
const hasRequirements = Object.keys(generatedFiles).some(f => f === 'requirements.txt');
|
||||||
Use python:3.12-slim as base. EXPOSE the correct port. CMD to start the app.
|
const depInstall = hasPyproject ? 'COPY pyproject.toml ./\nRUN pip install --no-cache-dir .' : hasRequirements ? 'COPY requirements.txt ./\nRUN pip install --no-cache-dir -r requirements.txt' : 'RUN pip install --no-cache-dir fastapi uvicorn';
|
||||||
Only output the Dockerfile content, nothing else.
|
const dockerPrompt = `Write a Dockerfile for this Python project.
|
||||||
|
|
||||||
Files: ${Object.keys(generatedFiles).join(', ')}
|
RULES:
|
||||||
Main app entry: ${Object.keys(generatedFiles).find(f => f.includes('main') || f.includes('app')) || Object.keys(generatedFiles)[0]}`;
|
- Base: python:3.12-slim (single stage, no multi-stage needed for Python)
|
||||||
|
- Install deps with pip ONLY (no poetry, no pipenv, no conda)
|
||||||
|
- ${depInstall}
|
||||||
|
- COPY all .py files
|
||||||
|
- EXPOSE 8000
|
||||||
|
- CMD ["uvicorn", "${mainFile.replace('.py','')}:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
|
- Only output Dockerfile content, no explanations
|
||||||
|
|
||||||
|
Files: ${Object.keys(generatedFiles).join(', ')}`;
|
||||||
const dockerfile = await kpnRun(agentPrompts.tester.model, dockerPrompt, false, 256);
|
const dockerfile = await kpnRun(agentPrompts.tester.model, dockerPrompt, false, 256);
|
||||||
if (dockerfile) generatedFiles['Dockerfile'] = dockerfile;
|
if (dockerfile) generatedFiles['Dockerfile'] = dockerfile;
|
||||||
pipelineStep('tester', 'Dockerfile', 'done', 'Dockerfile', dockerfile);
|
pipelineStep('tester', 'Dockerfile', 'done', 'Dockerfile', dockerfile);
|
||||||
|
|||||||
Reference in New Issue
Block a user