Back to projects

public work

Self-Hosted PostgreSQL 18 for Railway

A production-ready, SSL-enabled Postgres 18 deployment template published to Railway's marketplace during the window when no official option existed.

Filling a gap

When PostgreSQL 18 shipped, Railway didn't yet offer a self-hosted template for it, and the community templates that existed were showing low deployment success rates. Rather than wait, I built and published a template that worked reliably on the first deploy, so anyone on the platform could run Postgres 18 with one click.

Standing on the official template

I didn't set out to invent anything new here. The template is closely modeled on Railway's own official Postgres image, and the real work was in making Postgres 18 correct on the platform: SSL enabled out of the box, and handling the version's breaking change to the data directory layout, which moved from /var/lib/postgresql/data to /var/lib/postgresql/18/docker.

That data directory change is subtle but destructive: you can't upgrade an existing database just by bumping the image tag and restarting. The README documents this loudly, with backup and migration guidance, so nobody loses data to an innocent-looking version bump.

Adoption

The template found real users. Enough other Railway customers have deployed it that the marketplace kickbacks from those deployments have fully covered my own Railway usage since launch, and by my math, will keep covering it for the foreseeable future. For a small piece of public infrastructure packaging, that's a satisfying feedback loop: build the thing you needed, and it pays for the platform you built it on.

A Citus cluster follow-up

With the Postgres 18 template working, I applied the same approach to distributed Postgres: a Citus cluster template that deploys one coordinator and two worker nodes (scalable to twenty) communicating over Railway's private network, running Postgres 17 with Citus 13.2. Workers discover and register themselves with the coordinator automatically, so a horizontally scalable cluster comes up without manual wiring. It's a much more niche need and far less popular, but it's deployable with the same single click.

Built to be superseded

Railway now ships a native Postgres 18 offering, which is the right outcome. The template existed to cover a gap, not to compete with the platform. I expect its usage to taper off, and eventually the repository will be archived. It did its job during the window it was needed, and that was the point.