Deploying Turborepo project with a fastify workspace

AnonymousTRIAL

2 years ago

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           ║

╚═════════════════════════════════╝

….

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?

0 Replies

AnonymousTRIAL

2 years ago

dcb73c33-b411-4752-8665-de5c05f5d605


2 years 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


2 years ago

and since you now run from the root railway would properly detect pnpm and use pnpm to install your packages


AnonymousTRIAL

2 years ago

wow that worked. thank you!


2 years ago

awesome!


AnonymousTRIAL

a year 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

1219047577974997000


AnonymousTRIAL

a year ago

here's my package.json and railway config

1219047811354591200
1219047811576762400


a year 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 <#1006629907067064482> threads and post your build logs that you get with this tool