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:
@@ -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`);
|
termLog(`\n<span style="color:#d29922;font-weight:bold">[${step6}] DevOps</span> — Dockerfile`);
|
||||||
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 = Object.keys(generatedFiles).some(f => f === 'pyproject.toml');
|
const dockerPrompt = `Write a Dockerfile for this Python project using uv package manager.
|
||||||
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.
|
|
||||||
|
|
||||||
RULES:
|
RULES:
|
||||||
- Base: python:3.12-slim (single stage, no multi-stage needed for Python)
|
- Base: python:3.12-slim
|
||||||
- Install deps with pip ONLY (no poetry, no pipenv, no conda)
|
- Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
||||||
- ${depInstall}
|
- COPY pyproject.toml and then: RUN uv sync --no-dev
|
||||||
- COPY all .py files
|
- COPY all .py files
|
||||||
- EXPOSE 8000
|
- 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
|
- Only output Dockerfile content, no explanations
|
||||||
|
|
||||||
Files: ${Object.keys(generatedFiles).join(', ')}`;
|
Files: ${Object.keys(generatedFiles).join(', ')}`;
|
||||||
@@ -2254,9 +2251,9 @@ Files: ${Object.keys(generatedFiles).join(', ')}`;
|
|||||||
const readmePrompt = `Write a minimal README.md. Include ONLY:
|
const readmePrompt = `Write a minimal README.md. Include ONLY:
|
||||||
1. One-line description
|
1. One-line description
|
||||||
2. Quick start: docker compose up
|
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)
|
4. API endpoints (if applicable)
|
||||||
5. How to test
|
5. Testing: uv run pytest
|
||||||
Max 20 lines.
|
Max 20 lines.
|
||||||
|
|
||||||
Files: ${Object.keys(generatedFiles).join(', ')}`;
|
Files: ${Object.keys(generatedFiles).join(', ')}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user