From 6a11643a944e9f749bb25ac907012657f9e8a998 Mon Sep 17 00:00:00 2001 From: Tyler Lafleur Date: Fri, 19 Sep 2025 19:58:40 -0500 Subject: [PATCH] Comprehensive Railway deployment fix: eliminate cache mount errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MAJOR CHANGES: - Replace complex uv-based Dockerfile with simple pip-only approach - Add requirements.txt for standard Python dependency management - Remove all uv commands that might trigger cache mount behavior - Add .dockerignore for clean Railway build context - Add nixpacks.toml to force Dockerfile usage (disable auto-detection) - Update railway.json with explicit Docker configuration PROBLEM SOLVED: Railway 'Cache mount ID is not prefixed with cache key' error should be resolved by eliminating all potential sources of cache mount directives. DEPLOYMENT STRATEGY: - Single-stage Docker build using standard pip - Install graphiti-core from source with 'pip install .' - Install MCP dependencies with 'pip install -r requirements.txt' - No complex build tools or caching mechanisms - Explicit Railway Docker configuration 🚀 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude --- .dockerignore | 32 ++++++++++++++++++++++++++++++++ Dockerfile | 48 ++++++++++++------------------------------------ nixpacks.toml | 7 +++++++ railway.json | 5 +++-- requirements.txt | 5 +++++ 5 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 .dockerignore create mode 100644 nixpacks.toml create mode 100644 requirements.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..dde9bce7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,32 @@ +# Exclude files that don't need to be in the Docker build context +.git +.gitignore +.github/ +*.md +!README.md +.env* +!.env.example +.venv/ +__pycache__/ +*.pyc +*.pyo +*.pyd +.pytest_cache/ +.coverage +htmlcov/ +.tox/ +.mypy_cache/ +.DS_Store +node_modules/ +*.log +tests/ +docs/ +images/ +signatures/ +depot.json +ellipsis.yaml +conftest.py +pytest.ini +docker-compose*.yml +uv.lock +poetry.lock \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3265d7d2..cb5879f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,60 +1,36 @@ -# Railway-optimized Dockerfile for Graphiti MCP Server +# Ultra-simple Railway-compatible Dockerfile for Graphiti MCP Server FROM python:3.12-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ - curl \ - ca-certificates \ gcc \ && 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 +# Copy the entire project +COPY . . -# Add uv to PATH -ENV PATH="/root/.local/bin:${PATH}" +# Install graphiti-core from source using standard pip +RUN pip install --no-cache-dir . -# Configure uv for optimal Docker usage without cache mounts -ENV UV_COMPILE_BYTECODE=1 \ - UV_LINK_MODE=copy \ - UV_PYTHON_DOWNLOADS=never \ - MCP_SERVER_HOST="0.0.0.0" \ - PYTHONUNBUFFERED=1 +# Install MCP server dependencies using standard pip +RUN pip install --no-cache-dir -r requirements.txt # Create non-root user RUN groupadd -r app && useradd -r -d /app -g app app - -# First, copy and install the core graphiti library -COPY ./pyproject.toml ./README.md ./ -COPY ./graphiti_core ./graphiti_core - -# Build and install graphiti-core (no cache mount for Railway compatibility) -RUN uv build && \ - pip install dist/*.whl - -# Now set up the MCP server -COPY ./mcp_server/pyproject.toml ./mcp_server/uv.lock ./mcp_server/ -COPY ./mcp_server/graphiti_mcp_server.py ./ - -# Install MCP server dependencies (no cache mount for Railway compatibility) -RUN uv sync --frozen --no-dev - -# Change ownership to app user RUN chown -R app:app /app # Switch to non-root user USER app # Set environment variables for Railway +ENV PYTHONUNBUFFERED=1 ENV PORT=8000 -ENV MCP_SERVER_HOST=0.0.0.0 -# Expose port (Railway will override with PORT env var) +# Expose port EXPOSE $PORT -# Command to run the MCP server with SSE transport -# Railway will set PORT environment variable, host and port are configured via env vars -CMD ["uv", "run", "graphiti_mcp_server.py", "--transport", "sse"] \ No newline at end of file +# Change to MCP server directory and run +WORKDIR /app/mcp_server +CMD ["python", "graphiti_mcp_server.py", "--transport", "sse"] \ No newline at end of file diff --git a/nixpacks.toml b/nixpacks.toml new file mode 100644 index 00000000..515a82af --- /dev/null +++ b/nixpacks.toml @@ -0,0 +1,7 @@ +# Force Railway to use Dockerfile instead of auto-detection +[variables] +NIXPACKS_NO_CACHE = 'true' + +# Explicitly disable nixpacks to force Docker usage +[phases.build] +cmds = ["echo 'Using Dockerfile - nixpacks disabled'"] \ No newline at end of file diff --git a/railway.json b/railway.json index 072917a3..93ea5193 100644 --- a/railway.json +++ b/railway.json @@ -2,10 +2,11 @@ "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "dockerfile", - "dockerfilePath": "Dockerfile" + "dockerfilePath": "Dockerfile", + "buildArgs": {} }, "deploy": { - "startCommand": "uv run graphiti_mcp_server.py --transport sse", + "numReplicas": 1, "restartPolicyType": "on_failure", "restartPolicyMaxRetries": 10 } diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..fbf2766a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +# Railway-compatible requirements for Graphiti MCP Server +mcp>=1.5.0 +openai>=1.68.2 +azure-identity>=1.21.0 +python-dotenv \ No newline at end of file