blob: 8ebfa611beff63cc19f1a0a3e49a85a813d737a5 [file] [log] [blame]
# Stage 1: Build stage (Isolating the build env)
FROM python:3.10.16-bookworm AS builder
WORKDIR /home/work/
# Use uv instead of poetry for a more efficient, elegant, and unified py env management```
RUN pip install --no-cache-dir uv
# 1.1 Copy source code (merged for efficiency)
COPY . .
# 1.2 Install dependency
RUN cd /home/work/ && \
uv venv && \
. .venv/bin/activate && \
uv sync --extra llm
# Stage 2: Runtime stage
FROM python:3.10.16-slim-bookworm
LABEL maintainer="HugeGraph Docker Maintainers <dev@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 virtual environment and source code
COPY --from=builder --chown=work:work /home/work/.venv /home/work/.venv
COPY --from=builder --chown=work:work /home/work/hugegraph-llm/src /home/work/hugegraph-llm/src
COPY --from=builder --chown=work:work /home/work/hugegraph-llm/pyproject.toml /home/work/hugegraph-llm/pyproject.toml
COPY --from=builder --chown=work:work /home/work/hugegraph-python-client/src /home/work/hugegraph-python-client/src
USER work
ENV PATH="/home/work/.venv/bin:$PATH"
ENV PYTHONPATH="/home/work/hugegraph-llm/src:/home/work/hugegraph-python-client/src"
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 ["python", "-m", "hugegraph_llm.demo.rag_demo.app", "--host", "0.0.0.0", "--port", "8001"]