Deploying a Node js app from a turbo monorepo

I'm just trying to figure out if there are any docs on that. Having a relatively hard time with it; neither turbo nor railway has any info on it. I can't break up the repo as it's an important architecture choice we made. I can't be the first to want to do this, lol. 😓
49 Replies
Percy
Percy2y ago
Project ID: d3b7d643-d9b3-47a3-b033-01a9008c998a
alex.lazar
alex.lazar2y ago
d3b7d643-d9b3-47a3-b033-01a9008c998a
alex.lazar
alex.lazar2y ago
not exactly, I already set the root directory and the build/start command. Problem is I'd also need to set a custom install command as the app I am deploying is dependant on some other packages
Brody
Brody2y ago
shouldn't those packages be in your package.json?
alex.lazar
alex.lazar2y ago
For context, this is what we did for Vercel for our next app and it worked
alex.lazar
alex.lazar2y ago
the packages are in package.json indeed, but there's some code (prisma) that gets generated postinstall said code is used across apps and packages
Brody
Brody2y ago
are you wanting to deploy a frontend to railway?
alex.lazar
alex.lazar2y ago
Nope, just the backend We need a service that runs cron jobs to manipulate data
Brody
Brody2y ago
gotcha i think i can make this happen
alex.lazar
alex.lazar2y ago
Hey, any pointers and I'm more than happy tbh
Brody
Brody2y ago
build command: install command: start command:
alex.lazar
alex.lazar2y ago
Not sure I get it 🧐
Brody
Brody2y ago
fill those out 🙂
alex.lazar
alex.lazar2y ago
oh, suree build command: cd ../.. && yarn build --filter=data... install command: cd ../.. && yarn install We actually don't have a start command and it dawns on me this may be an issue? lol
Brody
Brody2y ago
haha yeah no start command means app wont start
alex.lazar
alex.lazar2y ago
I looked in the logs though, and it doesn't get to that point anyway though
Brody
Brody2y ago
well yes but i still need one
alex.lazar
alex.lazar2y ago
the error happens when trying to import one of the packages 'db-queries@*' is not in this registry. true that my bad, the start command is there, within the data workspace. just not in monorepo root
Brody
Brody2y ago
and i will also need your railway.json file, this can be found in the details tab of a deployment
alex.lazar
alex.lazar2y ago
so start command would be: yarn start
Brody
Brody2y ago
but i need the start command lol ah okay
alex.lazar
alex.lazar2y ago
yeah, basically since it's local we don't need to exit the app dir sure thing
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "cd ../../ && yarn build --filter=data..."
},
"deploy": {
"numReplicas": 1,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "cd ../../ && yarn build --filter=data..."
},
"deploy": {
"numReplicas": 1,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
ohh, I see, we just need to specify commands here right? This is actually pretty cool and easy so, I'd have:
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "cd ../../ && yarn build --filter=data...",
"installCommand": "cd ../.. && yarn install",
"startCommand": "yarn start"
},
"deploy": {
"numReplicas": 1,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "cd ../../ && yarn build --filter=data...",
"installCommand": "cd ../.. && yarn install",
"startCommand": "yarn start"
},
"deploy": {
"numReplicas": 1,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
right?
Brody
Brody2y ago
nope
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "cd ../../ && yarn build --filter=data...",
"nixpacksPlan": {
"phases": {
"install": {
"dependsOn": ["setup"],
"cmds": ["cd ../.. && yarn install"]
}
}
}
},
"deploy": {
"startCommand": "yarn start",
"numReplicas": 1,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "cd ../../ && yarn build --filter=data...",
"nixpacksPlan": {
"phases": {
"install": {
"dependsOn": ["setup"],
"cmds": ["cd ../.. && yarn install"]
}
}
}
},
"deploy": {
"startCommand": "yarn start",
"numReplicas": 1,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
untested, i dont know anything about your app, ive just made the railway.json with the commands you gave me
alex.lazar
alex.lazar2y ago
Sounds good to me Any docs on this in case I need to further play with it without bothering anybody?
Brody
Brody2y ago
wait thats wrong fixed
alex.lazar
alex.lazar2y ago
what was wrong?
Brody
Brody2y ago
forgot dependsOn to make sure isntall runs after setup and before start
alex.lazar
alex.lazar2y ago
oh, okay Thanks!
Brody
Brody2y ago
there are some lackluster docs here, they dont cover anything i just did though https://docs.railway.app/deploy/config-as-code#json how i know how to do this then? i read the schema and vscode will auto complete for me
Brody
Brody2y ago
like so
alex.lazar
alex.lazar2y ago
vscode will auto complete for me
github copilot is AMAZING EDIT: aaaand, that's not what happened lol
Brody
Brody2y ago
i dont use copilot the schema auto complete is a native vscode feature
alex.lazar
alex.lazar2y ago
that said, it unfortunately still fails with the same error 😓 apparently it's trying to install db-queries (a local package) from npm weird
Brody
Brody2y ago
id need to see the repo to make any further recommendations, im not even a js dev
alex.lazar
alex.lazar2y ago
I have an idea to change the way the packages get built and imported, but it's more work than I can do now (4 am here) Can we keep this post open until tomorrow?
Brody
Brody2y ago
of course
alex.lazar
alex.lazar2y ago
P.S.: I didn't expect a quick answer when I opened this
Brody
Brody2y ago
🙂
alex.lazar
alex.lazar2y ago
I'll come back to you after I try that tomorrow. Here's hoping. Thanks for the help Brody 🙏🏻
Brody
Brody2y ago
no problem 🙂
alex.lazar
alex.lazar2y ago
I have a potentially stupid guess that the issue may happen because railway tries to install packages with Nixpacks and our repo uses yarn workspaces 🧐
Brody
Brody2y ago
nixpacks is a app builder, not a package manager
alex.lazar
alex.lazar2y ago
ruled that out then
Brody
Brody2y ago
lol
alex.lazar
alex.lazar2y ago
So my idea of bundling the underlying packages with tsup didn't work, and it cost me half a day, lol. Scratched all that 😓
Brody
Brody2y ago
I'm out of ideas too
alex.lazar
alex.lazar2y ago
well, let's hope the weekend bestows me with new ideas. Thanks a lot for the help Brody
Brody
Brody2y ago
no problem
Want results from more Discord servers?
Add your server