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!
10 Replies
Project ID:
76d1c1bc-33a4-4702-9ed9-7bb7ebb7bdf6
76d1c1bc-33a4-4702-9ed9-7bb7ebb7bdf6
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
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
i dont know, maybe there is but i dont think so
because sleeping is rarely an efficient approach
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
perfect!! ill look into that. looks promising
it unfortunately doesn't apply here
Solution
but yeah healthcheck would do it
thanks for your ideas. I know now how to continue. mark it as closed!