File size: 1,613 Bytes
e454383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import textwrap
from pathlib import Path
from typing import List, Optional

BASE_HEADER = """# Auto-generated Dockerfile (do not edit manually)

FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim



WORKDIR /app/_backend



# Install system deps (adjust as needed)

RUN apt-get update && apt-get install -y --no-install-recommends git curl && rm -rf /var/lib/apt/lists/*



COPY _backend/requirements.txt .

RUN uv pip install --system -r requirements.txt

"""

FRONTEND_LAYER = """# Copy prebuilt frontend static files

WORKDIR /app

WORKDIR /app/_backend

"""

BACKEND_COPY = """# Copy backend (after frontend build to maximize caching)

COPY _backend/ .

"""

GRAPH_RAG_COPY_TEMPLATE = """# Include GraphRAG artifacts

COPY {artifact_rel_path} {container_target}

"""

FINAL_CMD = """EXPOSE 8000

CMD ["python", "api_meeting_minutes.py"]

"""

def build_dockerfile(frontend_build_cmd: str = "",

                     frontend_build_output: str = "out",

                     graphrag_artifact_paths: Optional[List[str]] = None) -> str:
    parts = [BASE_HEADER]
    parts.append(FRONTEND_LAYER)
    parts.append(BACKEND_COPY)

    if graphrag_artifact_paths:
        for p in graphrag_artifact_paths:
            rel = p.replace("\\", "/")
            parts.append(GRAPH_RAG_COPY_TEMPLATE.format(
                artifact_rel_path=rel,
                container_target=f"/app/{rel}"
            ))
    parts.append(FINAL_CMD)
    return textwrap.dedent("".join(parts))

def write_dockerfile(output_path: Path, content: str):
    output_path.write_text(content, encoding="utf-8")