R
Railway8mo ago
ar

Deploying Turborepo project with a fastify workspace

Hey everyone! I setup a turbo repo project that has the following structure: /apps: - apps/api (containing fastify server and its own package.json) <- this is what i want to deploy on railway - apps/web (containing a nextjs project) <- i want to deploy this on vercel later /pnpm-lock.yaml (seems like the content that would normally be in the apps/api pnpm.lock file are in this) I set the root directory in railway settings to /apps/api and changed the build and start commands to pnpm build and pnpm dev respectively. The build fails everytime and the logs look like this:
╔════════ Nixpacks v1.17.0 ═══════╗

║ setup │ nodejs_18, npm-9_x ║

║─────────────────────────────────║

║ install │ npm i ║

║─────────────────────────────────║

║ build │ pnpm build ║

║─────────────────────────────────║

║ start │ pnpm dev ║

╚═════════════════════════════════╝
╔════════ Nixpacks v1.17.0 ═══════╗

║ setup │ nodejs_18, npm-9_x ║

║─────────────────────────────────║

║ install │ npm i ║

║─────────────────────────────────║

║ build │ pnpm build ║

║─────────────────────────────────║

║ start │ pnpm dev ║

╚═════════════════════════════════╝
....
ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm i" did not complet
ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm i" did not complet
I think it fails because it runs npm instead of pnpm to install. But how do i fix that?
Solution:
with a turbo repo you wouldn't need to set a root directory in railway, you only need to have specific scripts (in the package.json at the root) to build and start each app in the turbo repo, like a build:api script that would only build the api app, and a start:api script that would only start the api app (I think turbo has some type of filter flag?) then you would only need to update the build and start commands in the service settings to the specific build and start scripts that build and...
Jump to solution
9 Replies
Percy
Percy8mo ago
Project ID: dcb73c33-b411-4752-8665-de5c05f5d605
ar
ar8mo ago
dcb73c33-b411-4752-8665-de5c05f5d605
Solution
Brody
Brody8mo ago
with a turbo repo you wouldn't need to set a root directory in railway, you only need to have specific scripts (in the package.json at the root) to build and start each app in the turbo repo, like a build:api script that would only build the api app, and a start:api script that would only start the api app (I think turbo has some type of filter flag?) then you would only need to update the build and start commands in the service settings to the specific build and start scripts that build and start the api app
Brody
Brody8mo ago
and since you now run from the root railway would properly detect pnpm and use pnpm to install your packages
ar
ar8mo ago
wow that worked. thank you!
Brody
Brody8mo ago
awesome!
ibrahimyaacob
ibrahimyaacob3mo ago
Hi @Brody, i'm using the a template repo that is similarly used by @ar and i did update the script in package.json and apparently i am getting this issue on the build step
No description
ibrahimyaacob
ibrahimyaacob3mo ago
here's my package.json and railway config
No description
No description
Brody
Brody3mo ago
there's not enough information in the screenshot as the actual error would be further up in the logs, so would you mind opening a new #✋|help thread and post your build logs that you get with this tool https://bookmarklets.up.railway.app/log-downloader/
Want results from more Discord servers?
Add your server
More Posts