Dockerfile generoidaan templatesta, ei LLM:llä — ei enää pip/uv sekaannuksia

Malli sekoitti pip:n ja uv:n syntaksin (pip install --system ei toimi).
Nyt Dockerfile rakennetaan suoraan templatesta generoiduista tiedostoista:
pyproject.toml → uv sync, requirements.txt → uv pip install, tai fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 08:11:00 +03:00
parent 702c9170ad
commit 7693269e5d

View File

@@ -2287,24 +2287,28 @@ ${Object.entries(generatedFiles).map(([n, c]) => `--- ${n} ---\n${c}`).join('\n\
pipelineStep('tester', 'Dockerfile', 'active', 'Dockerfile');
const mainFile = Object.keys(generatedFiles).find(f => f.includes('main') || f.includes('app')) || Object.keys(generatedFiles)[0];
const hasPyproject = 'pyproject.toml' in generatedFiles;
const hasRequirements = 'requirements.txt' in generatedFiles;
const pyFiles = Object.keys(generatedFiles).filter(f => f.endsWith('.py'));
const depStep = hasPyproject
? 'COPY pyproject.toml .\nRUN uv sync --no-dev'
: `RUN uv pip install --system fastapi uvicorn sqlalchemy`;
const dockerPrompt = `Write a Dockerfile. Output ONLY the Dockerfile, nothing else.
FROM python:3.12-slim
// Dockerfile-templatti: ei anneta mallin keksiä omaa
let depLines;
if (hasPyproject) {
depLines = 'COPY pyproject.toml .\nRUN uv sync --no-dev';
} else if (hasRequirements) {
depLines = 'COPY requirements.txt .\nRUN uv pip install --system -r requirements.txt';
} else {
depLines = 'RUN uv pip install --system fastapi uvicorn';
}
const dockerfileContent = `FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
${depStep}
${depLines}
COPY ${pyFiles.join(' ')} ./
EXPOSE 8000
CMD ["uv", "run", "uvicorn", "${mainFile.replace('.py','')}:app", "--host", "0.0.0.0", "--port", "8000"]
Adapt this template if needed. Project files: ${Object.keys(generatedFiles).join(', ')}`;
const dockerfile = await kpnRun(agentPrompts.tester.model, dockerPrompt, false, 256);
if (dockerfile) generatedFiles['Dockerfile'] = dockerfile;
pipelineStep('tester', 'Dockerfile', 'done', 'Dockerfile', dockerfile);
CMD ["uv", "run", "uvicorn", "${mainFile.replace('.py','')}:app", "--host", "0.0.0.0", "--port", "8000"]`;
// Generoidaan Dockerfile suoraan templatesta, ei mallilla
generatedFiles['Dockerfile'] = dockerfileContent;
termLog(` <span style="color:#3fb950">✓</span> Dockerfile generoitu (template)`);
pipelineStep('tester', 'Dockerfile', 'done', dockerfileContent, dockerfileContent);
// Vaihe 7: DevOps — docker-compose.yml
const step7 = step6 + 1;