From 5c25c7f9c16c8cddc843e5d5a3528cd25f12394b Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 7 Apr 2026 06:44:03 +0300 Subject: [PATCH] =?UTF-8?q?DevOps=20Dockerfile-prompti:=20pip-only,=20ei?= =?UTF-8?q?=20poetry=C3=A4/condaa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- network-poc/static/index.html | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/network-poc/static/index.html b/network-poc/static/index.html index be2d1fb..536a900 100644 --- a/network-poc/static/index.html +++ b/network-poc/static/index.html @@ -2212,14 +2212,22 @@ ${Object.entries(generatedFiles).map(([n, c]) => `--- ${n} ---\n${c}`).join('\n\ const step6 = step5 + 1; termLog(`\n[${step6}] DevOps — Dockerfile`); pipelineStep('tester', 'Dockerfile', 'active', 'Dockerfile'); - const dockerPrompt = `Write a Dockerfile for this project. Use multi-stage build: -- Stage 1 (builder): install dependencies -- Stage 2 (runtime): copy only what's needed, minimal image -Use python:3.12-slim as base. EXPOSE the correct port. CMD to start the app. -Only output the Dockerfile content, nothing else. + const mainFile = Object.keys(generatedFiles).find(f => f.includes('main') || f.includes('app')) || Object.keys(generatedFiles)[0]; + const hasPyproject = Object.keys(generatedFiles).some(f => f === 'pyproject.toml'); + const hasRequirements = Object.keys(generatedFiles).some(f => f === 'requirements.txt'); + 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'; + const dockerPrompt = `Write a Dockerfile for this Python project. -Files: ${Object.keys(generatedFiles).join(', ')} -Main app entry: ${Object.keys(generatedFiles).find(f => f.includes('main') || f.includes('app')) || Object.keys(generatedFiles)[0]}`; +RULES: +- 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); if (dockerfile) generatedFiles['Dockerfile'] = dockerfile; pipelineStep('tester', 'Dockerfile', 'done', 'Dockerfile', dockerfile);