This is an automated email from the ASF dual-hosted git repository. jin pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git
The following commit(s) were added to refs/heads/main by this push: new 8887a3b chore(llm): using nuitka to provide a binary/perf way for the service (#242) 8887a3b is described below commit 8887a3baa316fbbd7b89b0ebd77e2cdec55fd8ea Author: Linyu <94553312+weijing...@users.noreply.github.com> AuthorDate: Wed May 21 23:42:42 2025 +0800 chore(llm): using nuitka to provide a binary/perf way for the service (#242) follow #199 to build a new docker image using [Nuitka](https://github.com/Nuitka/Nuitka) in Dockerfile.nk - [x] Only simple tests have been conducted so far - [ ] more complete tests are still needed close #200 --------- Co-authored-by: imbajin <j...@apache.org> --- docker/Dockerfile.nk | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/docker/Dockerfile.nk b/docker/Dockerfile.nk new file mode 100644 index 0000000..ecefbe8 --- /dev/null +++ b/docker/Dockerfile.nk @@ -0,0 +1,46 @@ +# Stage 1: Build stage (Isolating the build env) +FROM python:3.10.16-bookworm AS builder + +WORKDIR /build/ + +# 1.1 Copy source code +COPY hugegraph-python-client/ ./hugegraph-python-client/ +COPY hugegraph-llm/ ./hugegraph-llm/ + +# 1.2 Install dependency +RUN apt update && \ + apt install -y --no-install-recommends build-essential patchelf && \ + python -m pip install nuitka && \ + pip install ./hugegraph-python-client && \ + pip install -r ./hugegraph-llm/requirements.txt && \ + cd hugegraph-llm/src && \ + export PYTHONPATH=/build/hugegraph-llm/src && \ + python -m nuitka --follow-imports --standalone --include-package-data=safehttpx,groovy,gradio,litellm --include-module=hugegraph_llm.demo.rag_demo.app,litellm.litellm_core_utils.tokenizers --include-data-dir=./hugegraph_llm/resources=hugegraph_llm/resources ./hugegraph_llm/demo/rag_demo/app.py && \ + mv app.* .. + +# Stage 2: Runtime stage +FROM python:3.10.16-slim-bookworm +LABEL maintainer="HugeGraph Docker Maintainers <d...@hugegraph.apache.org>" + +# Create non-root user & install 'curl' for healthcheck +RUN useradd -m -s /bin/bash work && \ + apt-get update && \ + apt-get install -y --no-install-recommends curl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /home/work/ + +COPY --from=builder --chown=work:work /build/hugegraph-llm/src /home/work/hugegraph-llm/src +COPY --from=builder --chown=work:work /build/hugegraph-llm/app.dist /home/work/hugegraph-llm/app.dist +COPY --from=builder --chown=work:work /build/hugegraph-llm/app.build /home/work/hugegraph-llm/app.build + +USER work + +WORKDIR /home/work/hugegraph-llm +VOLUME ["/home/work/hugegraph-llm/src/hugegraph_llm/resources"] +EXPOSE 8001 + +HEALTHCHECK --interval=60s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:8001/ || exit 1 + +CMD ["./app.dist/app.bin", "--host", "0.0.0.0", "--port", "8001"]