Straightforward way to setup postgresql-client 17 on a service with Railpack?
fredgig
PROOP

a month ago

I'd like to have Postgres tools like pg_dump and psql available in my service during pre-deploy and deploy phases so that I can run some DB migration ops on my Go service.

While this can be done by defining my own Dockerfile, I'd like to accomplish this with something like a Railpack config file or environment variable so that I can keep delegating the responsibility to Railpack for the golang setup.

The closest I've gotten to something simple was by setting the "RAILPACKDEPLOYAPT_PACKAGES" env var, but that registry only contains v15. My Railway Postgres services are on v17.

$20 Bounty

4 Replies

darseen
HOBBYTop 1% Contributor

a month ago

You need to create a nixpacks.toml file in your project root. Use the nixPkgs key with the ... syntax to append Postgres 17 tools to the default Go environment without replacing it.

Here is how the setup phase would look like:
[phases.setup]
nixPkgs = ["...", "postgresql_17"]


... ensures the default Go environment is preserved, and postgresql_17 installs the client tools (psql, pg_dump, etc.)


Try using RAILPACK_PACKAGES:

RAILPACK_PACKAGES="postgres@latest"

mikebianco

Try using RAILPACK_PACKAGES:RAILPACK_PACKAGES="postgres@latest"

fredgig
PROOP

a month ago

That won't work for me. postgres@latest appears to resolve to postgres@1.08 in the mise registry. I set it to postgres@17, which does find a match, but it doesn't contain a pre-built binary so the deployment attempts to compile it from source after having to add RAILPACK_BUILD_APT_PACKAGES="bison flex". It's a very slow process.


Ah, interesting! Another option would be github:theseus-rs/postgresql-binaries@17.6.0

I haven't tested this, but it should work just fine. Looks like this repo is the canonical way to install postgres binaries with mise.

Also, you could always use an apt install, but I always find those less appealing because it's hard to pin them to a particular version.


Loading...