How do I make pg_dump available?
I am getting this error:
exec: \"pg_dump\": executable file not found in $PATH"
I setup my Railway TOML config like this
And I can confirm the service is reading the toml command. What am I doing wrong?Solution:Jump to solution
Here's the full Dockerfile for reference
```Dockerfile
FROM golang:1.22.0-alpine
...
52 Replies
ive never been able to install postgresql with nixpacks, i always default to a Dockerfile, heres mine that would be a good starting point -
Thanks I'm explroign a docker file now
I am trying to figure out the steps
Are you sure I need to use
RUN apk add --update --no-cache postgresql${PG_VERSION}-client --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main
instead of something more declaraitive?wydm? you want pg_dump and thats how you install it
Kk
I'll try it out now
although you dont need to edge anymore, postgresql16-client is now on 3.19
Can you use a Dockerfile and Railway TOML together?
yeah but only the setup stuff would be used
I meant to configure the health server and retries, etc.
yeah you can still use the deploy stuff in a railway.toml file with a dockerfile
Kk
Thank you
no problem, let me know if that works for you
Getting some problems but not directly related
So it looks like this
Here are the logs
its still using nixpacks, make sure your Dockerfile is named correctly
Sorry virtualized scrolling I updated it https://gist.github.com/zaydek/9c58021b66941ab1ce94426fd982a594
Oh wait
OK so I'm using a monorepo
set the root directory in the service settings
Can you colocate a Dockerfile per command?
explain what you mean by that please
So I have like
cmd/foo/main.go
cmd/bar/main.go
How can I have a Dockerfile per service?
Can I customize the Dockerfile per service in Railway?
you could have a
Dockerfile.foo
and a Dockerfile.bar
and then choose what Dockerfile to use with RAILWAY_DOCKERFILE_PATH
Ah
Right
exactly
OK will try now thank you
Wow it worked
awsome
Solution
Here's the full Dockerfile for reference
Is there any reason not to always use a Docker file in general?
In my case it would allow me to always use the latest Go version without waiting for Nix
you lose caching, and now you have to maintain this dockerfile
OK so use Railway as is, then lean into Nix if you can, and finally use Docker if you have to?
As a general decision tree
exactly!
you could also use Dockerfiles to have a multi layered image where the final image that gets published is a small alpine or scratch image, this is what i do for really fast publish times
OK so for the smallest, fastest build what does that Dockerfile look like?
That sounds really interesting
in my example i have omitted that for brevity, but the Dockerfile you sent at first does do that
everything after the second
FROM
is a fresh small alpine image and doesnt contain all the bulky build tooling that the golang image doesBut how do you build Go then?
you do that under the first
FROM
golang imageOh you're saying basically the same as the script I'm using just without the Postgres step?
Alpine + Go then just Alpine?
no you still need postgres installed, since you still want pg_dump
Sorry I mean for another script where I want fast as possible deploys and there's no pg_dump involved
ah then yes
That is just golang-alpine to build then alpine to run, and that is generally faster than just Railway by itself?
I'd be really interested in like 10 second deploys
you couldn't get down to a total of 10 seconds, my multistage builds are ~13 seconds and the publish time is ~6 seconds
you dont get build caching like you do using nixpacks, but you skip installing all the nix stuff so its still generally faster in my experience
OK so your fastest deploys are like 20-30 seconds?
yeah but theres still the switch over time when railway tries to do the zero downtime deploys
Gotcha OK thanks for the help I'll close this out
Thank you
please dont close threads
Ah just leave it?
yeah
:salute:
and you still closed it anyway 😆
Did I? I didn't press anything