What's the best way to start services in a monorepo with a lot of services?
Looking at the docs I see commands like
npm run start:backend
so how does railway now which service is which? https://docs.railway.app/guides/monorepo#deploying-a-shared-monorepo
I have a turborepo with golang services in the following directory structure
/root
--/services
-- (golang services 1 folder each)
--/packages
--/apps
So now I am not sure how to start each monorepo service in each railway service59 Replies
Project ID:
f78d75b5-8972-4d61-8517-22bbccefb41e
f78d75b5-8972-4d61-8517-22bbccefb41e
Do i need to add each service start command to the root package.json?
@Brody This is what I have:
root package.json
yes you do, like a
start:backend
and start:frontend
etcit does fail build though
let me run that script for logs
beat you
dang
is pnpm-lock.yaml absent?
does the service need to have that? it's a golang app
it's in the root
does the go app need to access code from any other folder?
yeah, I have a shared package for other golang services
okay, do you have a
kangiten:build
script?oh i need to set a specific one too? whoops
i just had the turbo build one lol
go apps need to be built
yeah i just assumed it ran turbo build thats mb
youd want app specfic build scripts
gotcha
this package json gonna be long haha
do you have this set too? - https://nixpacks.com/docs/providers/node#corepack
Yeah
you taught me not too long ago
you may have added the new build script but you didnt configure the railway service to use it
ahh this error
WARN Local package.json exists, but node_modules missing, did you mean to install?
ive had it before
actually its a go error
i set provider to Go thoughlooks like it didnt take, try removing and readding node and go
same error
this must be the issue - i dont see Go in here
your providers list is only go though
Yeah ive been changing them
you want to set it to node and go
yep it still fails
might be time to move to a nixpacks.toml, i dont think you can pass in providers when you use the v2 builder
https://nixpacks.com/docs/guides/configuring-builds#change-what-providers-are-run
ok ill look into that, i ahvent used a nixpacks toml file before
Is this the correct way to do it. I added a
railway.toml
to the root of my monorepo with the following:
tbh i dont know the syntax for the railway.toml file off the top of my head.
so cant hurt to try
should this stay this way?
gotcha
yeah its not being used anyway
yeah it might have to be under a key, but the docs dont specify
under a key?
like [build]
sorry idk what its called in toml
yeah based on on the jsonschema it does, let me revisit
seems that even then it still doesnt work
syntax might be wrong, or you placed the file in the wrong location (need to be on root)
i forgot, the v2 builder does not support nixpack configs in a railway.toml/json
use a nixpacks.toml file
ohhh
same issue with nixpacks.toml
Solution
alright, Dockerfile time
or disable the v2 builder
do yall have any docs or examples for monorepos? i dont have a lot experience with dockerfiles in monorepo. disabling v2 didnt work
from what im seeing i guess i could make a dockerfile for each service with custom docker file path https://docs.railway.app/guides/dockerfiles
you switched the runtime back to legacy, that should stay on v2.
you wanted to switch off the new builder
but docs on how to write a Dockerfile would not be specific to railway so it would be out of the scope of our docs
no worries
you mean the new builder env?
yeah
but that looks like its not going to work, so dockerfile for sure
@Brody I see some people having the
Cache mount ID is not prefixed with cache key
which I am myself having but don't see the issue :Thonk:
actually just hardcoding the id without $service_id workedunfortunately you need to hardcode the service id
awesome
holy shit it works
thanks for all your help @Brody 🙏
no problem, dockerfiles imo are better for most things than doing a dance with nixpacks