Comprehensive Railway deployment fix: eliminate cache mount errors

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 <noreply@anthropic.com>
This commit is contained in:
Tyler Lafleur 2025-09-19 19:58:40 -05:00
parent a0258a4376
commit 6a11643a94
5 changed files with 59 additions and 38 deletions

32
.dockerignore Normal file
View file

@ -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

View file

@ -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 FROM python:3.12-slim
WORKDIR /app WORKDIR /app
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
gcc \ gcc \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Install uv using the installer script # Copy the entire project
ADD https://astral.sh/uv/install.sh /uv-installer.sh COPY . .
RUN sh /uv-installer.sh && rm /uv-installer.sh
# Add uv to PATH # Install graphiti-core from source using standard pip
ENV PATH="/root/.local/bin:${PATH}" RUN pip install --no-cache-dir .
# Configure uv for optimal Docker usage without cache mounts # Install MCP server dependencies using standard pip
ENV UV_COMPILE_BYTECODE=1 \ RUN pip install --no-cache-dir -r requirements.txt
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never \
MCP_SERVER_HOST="0.0.0.0" \
PYTHONUNBUFFERED=1
# Create non-root user # Create non-root user
RUN groupadd -r app && useradd -r -d /app -g app app 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 RUN chown -R app:app /app
# Switch to non-root user # Switch to non-root user
USER app USER app
# Set environment variables for Railway # Set environment variables for Railway
ENV PYTHONUNBUFFERED=1
ENV PORT=8000 ENV PORT=8000
ENV MCP_SERVER_HOST=0.0.0.0
# Expose port (Railway will override with PORT env var) # Expose port
EXPOSE $PORT EXPOSE $PORT
# Command to run the MCP server with SSE transport # Change to MCP server directory and run
# Railway will set PORT environment variable, host and port are configured via env vars WORKDIR /app/mcp_server
CMD ["uv", "run", "graphiti_mcp_server.py", "--transport", "sse"] CMD ["python", "graphiti_mcp_server.py", "--transport", "sse"]

7
nixpacks.toml Normal file
View file

@ -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'"]

View file

@ -2,10 +2,11 @@
"$schema": "https://railway.app/railway.schema.json", "$schema": "https://railway.app/railway.schema.json",
"build": { "build": {
"builder": "dockerfile", "builder": "dockerfile",
"dockerfilePath": "Dockerfile" "dockerfilePath": "Dockerfile",
"buildArgs": {}
}, },
"deploy": { "deploy": {
"startCommand": "uv run graphiti_mcp_server.py --transport sse", "numReplicas": 1,
"restartPolicyType": "on_failure", "restartPolicyType": "on_failure",
"restartPolicyMaxRetries": 10 "restartPolicyMaxRetries": 10
} }

5
requirements.txt Normal file
View file

@ -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