From 7693269e5d944318ae63c751aa1317c052eb26a8 Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 7 Apr 2026 08:11:00 +0300 Subject: [PATCH] =?UTF-8?q?Dockerfile=20generoidaan=20templatesta,=20ei=20?= =?UTF-8?q?LLM:ll=C3=A4=20=E2=80=94=20ei=20en=C3=A4=C3=A4=20pip/uv=20sekaa?= =?UTF-8?q?nnuksia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- network-poc/static/index.html | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/network-poc/static/index.html b/network-poc/static/index.html index 9c975cc..68a8a29 100644 --- a/network-poc/static/index.html +++ b/network-poc/static/index.html @@ -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(` Dockerfile generoitu (template)`); + pipelineStep('tester', 'Dockerfile', 'done', dockerfileContent, dockerfileContent); // Vaihe 7: DevOps — docker-compose.yml const step7 = step6 + 1;