Trying to set up deployments in a pnpm turbo repo

affanisautomated
PRO

7 days ago

I am trying to set up deployments for my apps. My folder structure is like this:

my-workspace/
├── apps/
│   ├── app-1-be/       # NestJS
│   ├── app-1-fe/       # React Vite
│   ├── app-2-be/       # NodeJS
│   └── app-2-fe/       # React Vite app
├── pnpm-workspace.yaml
├── package.json               # workspace root
├── pnpm-lock.yaml

My steps for app 1:

  1. Create 2 services.

  2. Connected the Git Repo

  3. Set the root directory to apps/app-1-be and apps/app-1-fe respectively

  4. Set up a railway.json in the app-1-be folder like this:

{
  "$schema": "https://railway.app/railway.schema.json",
  "build": {
    "builder": "NIXPACKS",
    "buildCommand": "cd ../.. && pnpm install --force && pnpm run build --filter=app-1-be && cd apps/app-1-be && npx prisma generate && npx prisma migrate deploy"
  },
  "deploy": {
    "startCommand": "pnpm run start:prod",
    "numReplicas": 1,
    "sleepApplication": false,
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10
  }
}
  1. Set up a railway.json in the app-1-fe folder like this:

{
    "$schema": "https://railway.app/railway.schema.json",
    "build": {
        "builder": "NIXPACKS",
        "buildCommand": "cd ../.. && pnpm install && pnpm run build --filter=app-1-fe"
    },
    "deploy": {
        "startCommand": "pnpm run preview",
        "numReplicas": 1,
        "sleepApplication": false,
        "restartPolicyType": "ON_FAILURE",
        "restartPolicyMaxRetries": 10
    }
}

Project ID: c243ded6-9e79-4752-857d-5b6f31fd8cc2

Closed$10 Bounty

1 Replies

affanisautomated
PRO

7 days ago

c243ded6-9e79-4752-857d-5b6f31fd8cc2


affanisautomated
PRO

7 days ago

Errors I am getting:

  • For the NestJS service, I am not sure why it is using npm i (I guess because there is no pnpm-lock in the folder rather it is only in the root of the workspace so I don't know how to get around this):

"npm i" did not complete successfully: exit code: 1

The error above is dependency issue and can be fixed with --force but it is using npm instead of pnpm and not my railway.json file

  • For app1 FE (vite react app), /bin/bash: line 1: pnpm: command not found


7 days ago

This thread as been deleted on Discord and will therefore be closed. Judging by the project's architecture, this is mostly related to the fact that it was configured as an isolated monorepo as opposed to a shared one.


Status changed to Closed uxuz 7 days ago