uv-paketinhallinta: Dockerfile, README ja pyproject.toml käyttävät uv:tä

Dockerfile kopioi uv:n ghcr.io/astral-sh/uv:latest -imagesta.
README ohjeistaa uv sync + uv run. pyproject.toml pysyy ennallaan
(uv-yhteensopiva formaatti).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 06:45:08 +03:00
parent 5c25c7f9c1
commit 842153a7ec

View File

@@ -2213,18 +2213,15 @@ ${Object.entries(generatedFiles).map(([n, c]) => `--- ${n} ---\n${c}`).join('\n\
termLog(`\n<span style="color:#d29922;font-weight:bold">[${step6}] DevOps</span> — Dockerfile`);
pipelineStep('tester', 'Dockerfile', 'active', 'Dockerfile');
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.
const dockerPrompt = `Write a Dockerfile for this Python project using uv package manager.
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}
- Base: python:3.12-slim
- Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
- COPY pyproject.toml and then: RUN uv sync --no-dev
- COPY all .py files
- EXPOSE 8000
- CMD ["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"]
- Only output Dockerfile content, no explanations
Files: ${Object.keys(generatedFiles).join(', ')}`;
@@ -2254,9 +2251,9 @@ Files: ${Object.keys(generatedFiles).join(', ')}`;
const readmePrompt = `Write a minimal README.md. Include ONLY:
1. One-line description
2. Quick start: docker compose up
3. Development: how to run without Docker
3. Development: uv sync && uv run uvicorn main:app --reload
4. API endpoints (if applicable)
5. How to test
5. Testing: uv run pytest
Max 20 lines.
Files: ${Object.keys(generatedFiles).join(', ')}`;