Deployment

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

AreaTerraform shape
App platformRailway project, environment, services, variables, and volumes
DatabaseNeon Postgres 17 project, branch, endpoint, database, and role
App imagesghcr.io/ctxpipe-ai/backend, worker, ui, and codesearch tagged by commit SHA
Graph databaseRailway service for FalkorDB
SecretsTerraform 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 init

For 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 plan

Apply only after the plan matches the intended environment:

terraform -chdir=infra apply

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.

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.