Prisma can't reach database server (during build)
Hello, I would like when deploying my application to synchronize the migrations with the database that I also have on railway. So I added this command during the build.
but unfortunately I have this error. I also had it when I put it on the script to start the application after building, and it only worked when I restarted the server.
34 Replies
Project ID:
2b4c4fbf-3975-4801-970c-47c4c97d9fe0
the private network is not available during build yet
So why I had the error also when commanding to start the application?
for
DATABASE_URL
variable i use the ref to ${{Postgres.DATABASE_PRIVATE_URL}}
so i have to use ${{Postgres.DATABASE_URL}}
?because you would need to have a 3 second delay before attempting to connect to a private service
yes you would have to use the public url if you want to run migrations during build, or continue using the private network and run the migrations at runtime before starting your app
what configuration do you recommend?
before you change anything, try enabling their new builder, I forget if it is a part of the private network, but I know it would be the end goal so maybe it's already implemented
https://railway.app/changelog/2024-05-24-builder-v2-beta
ok i try
i need a nixpacks.toml ?
not necessarily, why do you ask?
it does not take the configuration on railway directly
so he sends this back to me
Error: No start command could be found
I'm not sure what you mean, you need to set that variable as a service variable, have you?
How were you previously setting your start command?
it does not use the custom start command that I put in the parameters of my service
I did not change this command when I changed the builder version
I would therefore like to create a nixpacks configuration file, but the problem is that I don't know what to put in nixPckgs apart from nodejs
because when I don't use the nixpacks file, by default it uses nodejs, npm and openssl
so you already have a nixpacks.toml file?
I tried to put it on to see what we could do, but I took it off
okay, you're all over the place and I don't know what the current issue is.
so let's start off without a nixpacks.toml file, what kind of app do you have?
i have a nestjs app
my question is but is it recommended to do the migration during the build or start?
start because then you can use the private network. but I have asked you to try running the migration during build with the v2 builder
yes but i need nixpacks.toml to run the v2 builder
why is that
I'm going to put the whole context back
I had the bug concerning prisma which could not connect to my database during the build via the internal url, because during the build there is no access to the internal network. You therefore suggested that I use the builder v2 which could potentially solve this problem. So I activated the builder v2 via the variables. But I noticed that it does not find a start command even though I put a custom start command on the settings of my backend service (on railway directly). So I wanted to create a nixpacks.toml configuration file to define the build, start, etc. commands... But the problem is that I noticed that I didn't know what to put in nixPcks in the setup phase. Because without a nixpacks.toml file, it has nodejs_20, npm_9 and openssl as default. And in mine I just put nodejs, and I didn't know if I should put other things.
So I'm just wondering if it's better to migrate my database during start or during build. To me this makes more sense during the build. But in this case, I would like someone to explain the nixpacks.toml configuration file to me.
@Brody If you have any questions do not hesitate. sorry I wasn't on my pc before
I'm sorry but I don't currently have the time to read all that, instead I would greatly appreciate if you could directly answer my previous question
I noticed that it does not find a start command even though I put a custom start command on the settings of my backend service (on railway directly).
but the builder v2 return this
thank you for this clear and concise answer, try adding a
start
script to your package.json insteadI see that it deletes lots of files, why?
60 store paths deleted, 512.58 MiB freedthis v2 is used to take up less space for snapshots?
the new builder is much more verbose, I don't think you need to pay much mind to what it prints
it takes much longer
it fail
after 10min
with what error
nothing
it's the last logs
i come back to build v1
and i create this nixpacks.toml file