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