Failing to deploy a NestJs api in Railways UI from a Turbo monorepo

Hey all, I have a turbo monorepo repo and inside /apps/api is a NestJs api. I want to use Railway to deploy the api (and db), however I'm struggling to get this to build with nixpacks If I just set the directory to apps/api, build command to yarn run build and start command to yarn run start:prod from the raiway.app UI, the error it spits out says that yarn is not a command It also does not acknowledge npm as a command. What is the proper way to have my yarn run build and yarn run start:prod called from my turbo monorepo's apps/api subfolder?
4 Replies
Percy
Percy2y ago
Project ID: 5dbab68a-8e86-4f19-b758-47e6516c3028
Carson
Carson2y ago
5dbab68a-8e86-4f19-b758-47e6516c3028 In the base case described above, the specific error is:
#8 [4/5] RUN yarn run build
#8 sha256:4f315b61e2b47196686f7c58053564118e333afb63cfc9d13d6082a8a82d6073

#8 0.387 /bin/bash: line 1: yarn: command not found

#8 ERROR: executor failed running [/bin/bash -ol pipefail -c yarn run build]: exit code: 127
-----
> [4/5] RUN yarn run build:
-----

executor failed running [/bin/bash -ol pipefail -c yarn run build]: exit code: 127

Error: Docker build failed
#8 [4/5] RUN yarn run build
#8 sha256:4f315b61e2b47196686f7c58053564118e333afb63cfc9d13d6082a8a82d6073

#8 0.387 /bin/bash: line 1: yarn: command not found

#8 ERROR: executor failed running [/bin/bash -ol pipefail -c yarn run build]: exit code: 127
-----
> [4/5] RUN yarn run build:
-----

executor failed running [/bin/bash -ol pipefail -c yarn run build]: exit code: 127

Error: Docker build failed
Also, in the terminal locally, if I run nixpacks plan apps/api, it outputs what looks like a successful plan, knows to setup yarn and such:
{
"providers": [],
"buildImage": "ghcr.io/railwayapp/nixpacks:debian-1670285109",
"variables": {
"CI": "true",
"NIXPACKS_METADATA": "node",
"NODE_ENV": "production",
"NPM_CONFIG_PRODUCTION": "false"
},
"phases": {
"build": {
"dependsOn": [
"install"
],
"cmds": [
"yarn run build"
],
"cacheDirectories": [
"node_modules/.cache"
]
},
"install": {
"dependsOn": [
"setup"
],
"cmds": [
"yarn install --frozen-lockfile"
],
"cacheDirectories": [
"/usr/local/share/.cache/yarn/v6"
],
"paths": [
"/app/node_modules/.bin"
]
},
"setup": {
"nixPkgs": [
"nodejs-16_x",
"yarn-1_x"
],
"nixOverlays": [
"https://github.com/railwayapp/nix-npm-overlay/archive/main.tar.gz"
],
"nixpkgsArchive": "a0b7e70db7a55088d3de0cc370a59f9fbcc906c3"
}
},
"start": {
"cmd": "yarn run start"
}
}
{
"providers": [],
"buildImage": "ghcr.io/railwayapp/nixpacks:debian-1670285109",
"variables": {
"CI": "true",
"NIXPACKS_METADATA": "node",
"NODE_ENV": "production",
"NPM_CONFIG_PRODUCTION": "false"
},
"phases": {
"build": {
"dependsOn": [
"install"
],
"cmds": [
"yarn run build"
],
"cacheDirectories": [
"node_modules/.cache"
]
},
"install": {
"dependsOn": [
"setup"
],
"cmds": [
"yarn install --frozen-lockfile"
],
"cacheDirectories": [
"/usr/local/share/.cache/yarn/v6"
],
"paths": [
"/app/node_modules/.bin"
]
},
"setup": {
"nixPkgs": [
"nodejs-16_x",
"yarn-1_x"
],
"nixOverlays": [
"https://github.com/railwayapp/nix-npm-overlay/archive/main.tar.gz"
],
"nixpkgsArchive": "a0b7e70db7a55088d3de0cc370a59f9fbcc906c3"
}
},
"start": {
"cmd": "yarn run start"
}
}
However, when I run it in the UI separately, the plan does not include the setup step. Just build & start Oh my god I'm an idiot... api was a separate repo. What was being pushed in this main repo was just the current commit hash of that inner repo, not the code itself. This caused a disconnect. Deleted the inner repo and moved the old code to a regular folder of the monorepo instead, and now I get passed the issues. Fingers crossed this was it 🤞
angelo
angelo2y ago
Was this it? hehe