deploying-to-railway
Deploying to Railway
Guide for deploying Python services to Railway.
Prerequisites
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
Basic Workflow
1. Link Project
cd /path/to/service
railway link
# Select workspace and project (or create new)
2. Add PostgreSQL (if needed)
railway add
# Select: Database → Postgres
IMPORTANT: Standard Postgres does NOT have pgvector. For vector search:
- Delete standard Postgres
- Add service from template: https://railway.com/deploy/pgvector-latest
3. Set Environment Variables
railway variables set KEY="value"
# Reference another service's variable:
railway variables set 'DATABASE_URL=${{Postgres.DATABASE_URL}}'
railway variables set 'DATABASE_URL=${{pgvector.DATABASE_URL}}'
4. Deploy
railway up --detach
5. Get Domain
railway domain
# Returns: https://service-production.up.railway.app
Multi-Service Pattern (API + Worker)
Deploy API Service
railway link # Link to main service
railway up --detach
Add Worker Service
railway add --service worker
railway service link worker
railway variables set 'DATABASE_URL=${{pgvector.DATABASE_URL}}'
railway variables set OPENAI_API_KEY="$OPENAI_API_KEY"
# Set start command in dashboard or railway.toml
railway up --detach
Gotchas
- pgvector not available - Use pgvector template, not standard Postgres
- Interactive prompts - Some commands need interactive mode (run manually)
- Variable references - Use
${{ServiceName.VARIABLE}}syntax - Dockerfile required - For custom Python services, include Dockerfile
- Procfile - Railway can use Procfile for multi-process apps
Useful Commands
railway status # Current project/service
railway variables # List environment variables
railway logs # View service logs
railway service status # Deployment status
railway redeploy --yes # Force redeploy
Example Dockerfile
FROM python:3.11-slim
WORKDIR /app
RUN apt-get update && apt-get install -y libpq-dev gcc && rm -rf /var/lib/apt/lists/*
COPY pyproject.toml ./
COPY myapp/ ./myapp/
RUN pip install --no-cache-dir .
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "2", "myapp.app:app"]
More from cpfiffer/central
interacting-with-x
Full interaction with X (Twitter) - post, read, reply, like, retweet, follow. Use when operating on X as an additional social environment alongside ATProtocol.
48interacting-with-agents
Guide for interacting with AI agents on ATProtocol. Use when engaging with other agents, reading their cognition, or navigating the agent ecosystem. Includes agent identification and the comind collective.
18using-xrpc-indexer
Query the comind semantic search API for cognition records. Use when searching thoughts, concepts, memories, or hypotheses. Provides vector similarity search over network.comind.* collections.
15working-with-subagents
Guide for deploying and prompting my stateful subagents (scout, coder, memory). Use when delegating tasks or parallelizing work.
15managing-memory
Guide for managing agent memory blocks. Use when inspecting, updating, creating, auditing, or restructuring memory blocks for yourself or subagents. Covers the memory tool (self), Letta API (subagents), auditing utilization, and invoking the memory agent for major restructuring.
14agent-profile
Publish and query agent profiles on ATProto. Unified schema combining identity (transparency) and registration (discovery). Use when setting up a new agent, querying other agents, or updating your profile.
14