Template pipeline: docker-compose.yml ja .dockerignore mukaan generointiin
Jokainen generoitu projekti sisältää nyt: - Dockerfile (oli jo) - docker-compose.yml (uusi: build + portti 8000 + named volume) - .dockerignore (uusi: .venv, __pycache__, *.db, .git) Testattu: docker compose build + kontin käynnistys + API-kutsu OK.
This commit is contained in:
@@ -1337,6 +1337,15 @@ Blog → Author: name,email,bio(Text|None) / Post: title, content(Text), author_
|
|||||||
return `FROM python:3.12-slim\nCOPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv\nENV UV_CACHE_DIR=/tmp/uv-cache\nWORKDIR /app\nCOPY pyproject.toml .\nRUN uv sync\nCOPY *.py .\nRUN useradd -m appuser && chown -R appuser:appuser /app /tmp/uv-cache\nUSER appuser\nEXPOSE 8000\nCMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]\n`;
|
return `FROM python:3.12-slim\nCOPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv\nENV UV_CACHE_DIR=/tmp/uv-cache\nWORKDIR /app\nCOPY pyproject.toml .\nRUN uv sync\nCOPY *.py .\nRUN useradd -m appuser && chown -R appuser:appuser /app /tmp/uv-cache\nUSER appuser\nEXPOSE 8000\nCMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tmplDockerCompose(spec) {
|
||||||
|
const name = (spec.project_name || 'app').toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
||||||
|
return `services:\n app:\n build: .\n container_name: ${name}\n ports:\n - "8000:8000"\n volumes:\n - app-data:/app/data\n restart: unless-stopped\n\nvolumes:\n app-data:\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tmplDockerignore() {
|
||||||
|
return `.venv\n__pycache__\n*.pyc\n*.db\n.pytest_cache\n.git\n`;
|
||||||
|
}
|
||||||
|
|
||||||
function tmplGenerate(spec) {
|
function tmplGenerate(spec) {
|
||||||
return {
|
return {
|
||||||
'models.py': tmplModels(spec),
|
'models.py': tmplModels(spec),
|
||||||
@@ -1345,6 +1354,8 @@ Blog → Author: name,email,bio(Text|None) / Post: title, content(Text), author_
|
|||||||
'test_main.py': tmplTests(spec),
|
'test_main.py': tmplTests(spec),
|
||||||
'pyproject.toml': tmplPyproject(spec),
|
'pyproject.toml': tmplPyproject(spec),
|
||||||
'Dockerfile': tmplDockerfile(),
|
'Dockerfile': tmplDockerfile(),
|
||||||
|
'docker-compose.yml': tmplDockerCompose(spec),
|
||||||
|
'.dockerignore': tmplDockerignore(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1385,7 +1396,7 @@ Blog → Author: name,email,bio(Text|None) / Post: title, content(Text), author_
|
|||||||
// === Vaihe 3: Koodigenerointi templateista ===
|
// === Vaihe 3: Koodigenerointi templateista ===
|
||||||
const files = tmplGenerate(spec);
|
const files = tmplGenerate(spec);
|
||||||
const fileOrder = Object.keys(files);
|
const fileOrder = Object.keys(files);
|
||||||
const agentMap = { 'models.py': 'data', 'schemas.py': 'coder', 'main.py': 'coder', 'test_main.py': 'qa', 'pyproject.toml': 'coder', 'Dockerfile': 'tester' };
|
const agentMap = { 'models.py': 'data', 'schemas.py': 'coder', 'main.py': 'coder', 'test_main.py': 'qa', 'pyproject.toml': 'coder', 'Dockerfile': 'tester', 'docker-compose.yml': 'tester', '.dockerignore': 'tester' };
|
||||||
const agentNames = { data: 'Data Engineer', coder: 'Coder', qa: 'QA', tester: 'DevOps' };
|
const agentNames = { data: 'Data Engineer', coder: 'Coder', qa: 'QA', tester: 'DevOps' };
|
||||||
|
|
||||||
for (let i = 0; i < fileOrder.length; i++) {
|
for (let i = 0; i < fileOrder.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user