Terraform
Manage self-hosted ctx| infrastructure with Terraform.
The repo includes a Terraform stack in infra/ for managed infrastructure. It
currently models the ctx| Railway and Neon deployment path, with app services
pulling versioned images from GitHub Container Registry.
What the included stack manages
| Area | Terraform shape |
|---|---|
| App platform | Railway project, environment, services, variables, and volumes |
| Database | Neon Postgres 17 project, branch, endpoint, database, and role |
| App images | ghcr.io/ctxpipe-ai/backend, worker, ui, and codesearch tagged by commit SHA |
| Graph database | Railway service for FalkorDB |
| Secrets | Terraform variables passed into provider-managed service variables |
Initialize state
infra/backend.tf expects an S3-compatible backend. The checked-in README shows
Cloudflare R2 as the reference backend. Initialize from the repo root:
terraform -chdir=infra initFor production state, pass backend settings at init time and keep credentials out of the repo.
Plan and apply
Set the required Terraform variables through your CI secret store or local environment, then review the plan:
terraform -chdir=infra planApply only after the plan matches the intended environment:
terraform -chdir=infra applyOptional provider connectors are enabled when their complete credential set is supplied. Keep GitHub, Slack, Linear, Notion, and Atlassian values in the CI secret store used for Terraform inputs; each provider still requires its operator-side App, OAuth, callback, and webhook configuration.
Image rollout
The deployment path expects CI to build and push app images, then pass the image tag into Terraform:
terraform -chdir=infra apply -var="image_tag=<commit-sha>"This keeps infrastructure changes and application rollouts reviewable in the same workflow.
Observability
This stack is the hosted Railway layout. It does not deploy Langfuse or
ClickStack. The module always sets OTEL_EXPORTER_OTLP_* from
otel_otlp_endpoint, which defaults to ctx|'s hosted collector
https://telemetry.ctxpipe.ai, and requires otel_otlp_headers. If you reuse
the module, override both; to disable export, remove otel_shared_env from
the module. See Configuration.
When to customize
Fork or extend the Terraform module when you need:
- A different container platform.
- A different Postgres provider.
- Externalized graph database infrastructure.
- Separate environments for staging, preview, and production.
- Provider-specific secrets, logging, or networking controls.