Define a build order / setting a build delay (build NextJS after Strapi)

Hi! I have set up a project on Railway which works really great. My project uses a postgres database, strapi as my website backend and nextjs as my frontend. The nextjs frontend is communicating with my strapi backend via a graphql API. However, when triggering a build via git push, my services get redeployed all at the same time. The frontend relies on the backend, so when there is no backend, the frontend build will fail. Usually my backend build takes longer, so I have to manually redeploy the frontend. I already thought about a workaround, which is to use a prebuild-script for my frontend, which simply sleeps for a given amount of time (possibly also with a env variable). Is there a better way, or should I go with my idea? Thanks in advance!
Solution:
but yeah healthcheck would do it
Jump to solution
10 Replies
Percy
Percy14mo ago
Project ID: 76d1c1bc-33a4-4702-9ed9-7bb7ebb7bdf6
Fabian Richter
Fabian Richter14mo ago
76d1c1bc-33a4-4702-9ed9-7bb7ebb7bdf6
Floris
Floris14mo ago
maybe a silly idea but you're given a /health endpoint to verify whether a specific function flow in your deploy is met technically you could make your backend return 200 on a successful boot
Fabian Richter
Fabian Richter14mo ago
well that sounds good, honestly i thought of that, but I also thought, that there might be some railway variable which I can set to delay a build or something. but like this it is also totally fine i guess
Floris
Floris14mo ago
i dont know, maybe there is but i dont think so because sleeping is rarely an efficient approach
jonbeau
jonbeau14mo ago
I recall from the docs a phase dependency where you can have one part of the build be dependent on another. https://nixpacks.com/docs/configuration/file#phase-dependencies but maybe it doesn't apply here
Configuration File Reference | Nixpacks
App source + Nix packages + Docker = Image
Fabian Richter
Fabian Richter14mo ago
perfect!! ill look into that. looks promising
Brody
Brody14mo ago
it unfortunately doesn't apply here
Solution
Brody
Brody14mo ago
but yeah healthcheck would do it
Fabian Richter
Fabian Richter14mo ago
thanks for your ideas. I know now how to continue. mark it as closed!
Want results from more Discord servers?
Add your server