diff --git a/.github/workflows/release-server-container.yml b/.github/workflows/release-server-container.yml index a846fcb8..9afb3bd5 100644 --- a/.github/workflows/release-server-container.yml +++ b/.github/workflows/release-server-container.yml @@ -27,6 +27,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.workflow_run.head_sha || github.ref }} - name: Set up Python 3.11 uses: actions/setup-python@v5 @@ -45,17 +48,27 @@ jobs: VERSION="${{ github.event.inputs.version }}" echo "Using manual input version: $VERSION" else - # Extract from the triggering tag - VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//') + # When triggered by workflow_run, get the tag that triggered the PyPI release + # The PyPI workflow is triggered by tags matching v*.*.* + VERSION=$(git tag --points-at HEAD | grep '^v[0-9]' | head -1 | sed 's/^v//') + if [ -z "$VERSION" ]; then - echo "Could not determine version from git tags" + # Fallback: check pyproject.toml version + VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") + echo "Version from pyproject.toml: $VERSION" + else + echo "Version from git tag: $VERSION" + fi + + if [ -z "$VERSION" ]; then + echo "Could not determine version" exit 1 fi - echo "Extracted version from tag: $VERSION" fi - # Validate it's a stable release (no pre, rc, alpha, beta) - if [[ $VERSION =~ (pre|rc|alpha|beta) ]]; then + # Validate it's a stable release - catch all Python pre-release patterns + # Matches: pre, rc, alpha, beta, a1, b2, dev0, etc. + if [[ $VERSION =~ (pre|rc|alpha|beta|a[0-9]+|b[0-9]+|\.dev[0-9]*) ]]; then echo "Skipping pre-release version: $VERSION" echo "skip=true" >> $GITHUB_OUTPUT exit 0 @@ -132,6 +145,8 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | GRAPHITI_VERSION=${{ steps.version.outputs.version }} + BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} + VCS_REF=${{ github.sha }} - name: Summary if: steps.version.outputs.skip != 'true' diff --git a/Dockerfile b/Dockerfile index e0142f6b..06095f84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,4 @@ # syntax=docker/dockerfile:1.9 -FROM python:3.12-slim as builder - -# Build arguments for version tracking -ARG GRAPHITI_VERSION -ARG BUILD_DATE -ARG VCS_REF - -WORKDIR /app - -# Install system dependencies for building -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc \ - curl \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -# Install uv using the installer script -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 optimal Docker usage -ENV UV_COMPILE_BYTECODE=1 \ - UV_LINK_MODE=copy \ - UV_PYTHON_DOWNLOADS=never - -# Copy and build main graphiti-core project -COPY ./pyproject.toml ./README.md ./ -COPY ./graphiti_core ./graphiti_core - -# Build graphiti-core wheel -RUN --mount=type=cache,target=/root/.cache/uv \ - uv build - -# Install the built wheel to make it available for server -RUN --mount=type=cache,target=/root/.cache/uv \ - pip install dist/*.whl - -# Runtime stage - build the server here FROM python:3.12-slim # Inherit build arguments for labels @@ -74,12 +35,14 @@ ENV UV_COMPILE_BYTECODE=1 \ # Create non-root user RUN groupadd -r app && useradd -r -d /app -g app app -# Copy graphiti-core wheel from builder -COPY --from=builder /app/dist/*.whl /tmp/ - -# Install graphiti-core wheel first +# Install graphiti-core from PyPI +# If GRAPHITI_VERSION is provided, install that specific version; otherwise install latest RUN --mount=type=cache,target=/root/.cache/uv \ - uv pip install --system /tmp/*.whl + if [ -n "$GRAPHITI_VERSION" ]; then \ + uv pip install --system "graphiti-core==$GRAPHITI_VERSION"; \ + else \ + uv pip install --system graphiti-core; \ + fi # Set up the server application WORKDIR /app @@ -94,8 +57,11 @@ RUN --mount=type=cache,target=/root/.cache/uv \ ARG INSTALL_FALKORDB=false RUN --mount=type=cache,target=/root/.cache/uv \ if [ "$INSTALL_FALKORDB" = "true" ]; then \ - WHEEL=$(ls /tmp/*.whl | head -n 1); \ - uv pip install "$WHEEL[falkordb]"; \ + if [ -n "$GRAPHITI_VERSION" ]; then \ + uv pip install --system "graphiti-core[falkordb]==$GRAPHITI_VERSION"; \ + else \ + uv pip install --system "graphiti-core[falkordb]"; \ + fi; \ fi # Change ownership to app user