Download _backend/cli/docker_builder.py from IOE-IFAD/test: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/spaces/IOE-IFAD/test/resolve/main/_backend/cli/docker_builder.py
- Command line
-
hf download hf://spaces/IOE-IFAD/test/_backend/cli/docker_builder.py
-
curl -L -o docker_builder.py https://huggingface.co/spaces/IOE-IFAD/test/resolve/main/_backend/cli/docker_builder.py
1.61 kB
| 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") | |