Address additional review concerns: 1. **Fix dependency installation order** - Install server deps first with uv sync, then upgrade graphiti-core to desired PyPI version using --upgrade flag. This prevents stale uv.lock (pinned to 0.13.2) from downgrading our target version. 2. **Optimize FalkorDB installation** - Combine graphiti-core installation with FalkorDB extra in single command, avoiding redundant package reinstall. 3. **Add --upgrade flag** - Ensures the specific PyPI version takes precedence over lockfile version. The installation sequence is now: - uv sync (server deps + graphiti-core 0.13.2 from lock) - uv pip install --upgrade graphiti-core==TARGET_VERSION (upgrades to desired version) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
78 lines
2.6 KiB
Docker
78 lines
2.6 KiB
Docker
# syntax=docker/dockerfile:1.9
|
|
FROM python:3.12-slim
|
|
|
|
# Inherit build arguments for labels
|
|
ARG GRAPHITI_VERSION
|
|
ARG BUILD_DATE
|
|
ARG VCS_REF
|
|
|
|
# OCI image annotations
|
|
LABEL org.opencontainers.image.title="Graphiti FastAPI Server"
|
|
LABEL org.opencontainers.image.description="FastAPI server for Graphiti temporal knowledge graphs"
|
|
LABEL org.opencontainers.image.version="${GRAPHITI_VERSION}"
|
|
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
|
LABEL org.opencontainers.image.revision="${VCS_REF}"
|
|
LABEL org.opencontainers.image.vendor="Zep AI"
|
|
LABEL org.opencontainers.image.source="https://github.com/getzep/graphiti"
|
|
LABEL org.opencontainers.image.documentation="https://github.com/getzep/graphiti/tree/main/server"
|
|
LABEL io.graphiti.core.version="${GRAPHITI_VERSION}"
|
|
|
|
# Install uv using the installer script
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ADD https://astral.sh/uv/install.sh /uv-installer.sh
|
|
RUN sh /uv-installer.sh && rm /uv-installer.sh
|
|
ENV PATH="/root/.local/bin:$PATH"
|
|
|
|
# Configure uv for runtime
|
|
ENV UV_COMPILE_BYTECODE=1 \
|
|
UV_LINK_MODE=copy \
|
|
UV_PYTHON_DOWNLOADS=never
|
|
|
|
# Create non-root user
|
|
RUN groupadd -r app && useradd -r -d /app -g app app
|
|
|
|
# Set up the server application first
|
|
WORKDIR /app
|
|
COPY ./server/pyproject.toml ./server/README.md ./server/uv.lock ./
|
|
COPY ./server/graph_service ./graph_service
|
|
|
|
# Install server dependencies (without graphiti-core from lockfile)
|
|
# Then install graphiti-core from PyPI at the desired version
|
|
# This prevents the stale lockfile from pinning an old graphiti-core version
|
|
ARG INSTALL_FALKORDB=false
|
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
uv sync --frozen --no-dev && \
|
|
if [ -n "$GRAPHITI_VERSION" ]; then \
|
|
if [ "$INSTALL_FALKORDB" = "true" ]; then \
|
|
uv pip install --system --upgrade "graphiti-core[falkordb]==$GRAPHITI_VERSION"; \
|
|
else \
|
|
uv pip install --system --upgrade "graphiti-core==$GRAPHITI_VERSION"; \
|
|
fi; \
|
|
else \
|
|
if [ "$INSTALL_FALKORDB" = "true" ]; then \
|
|
uv pip install --system --upgrade "graphiti-core[falkordb]"; \
|
|
else \
|
|
uv pip install --system --upgrade graphiti-core; \
|
|
fi; \
|
|
fi
|
|
|
|
# Change ownership to app user
|
|
RUN chown -R app:app /app
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PATH="/app/.venv/bin:$PATH"
|
|
|
|
# Switch to non-root user
|
|
USER app
|
|
|
|
# Set port
|
|
ENV PORT=8000
|
|
EXPOSE $PORT
|
|
|
|
# Use uv run for execution
|
|
CMD ["uv", "run", "uvicorn", "graph_service.main:app", "--host", "0.0.0.0", "--port", "8000"]
|