Can't deploy nx monorepo nestjs app

jossic
TRIAL

a year ago

Hello,
I'm trying to deploy an api which is on a NX monorepo on folder apps/api.
I tried with different commands, different root folders, but nothing work, do you have any solutions or guide about this issue?
Thanks

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

7 Replies

a year ago

For an NX monorepo you'd generally want to deploy from the root folder and have specific build and start scripts to build and start your desired application.


jossic
TRIAL

a year ago

Yes that's what I have, but, the strange thing is that de deploy fail only when I try do upgrade my account and take a paid version... Otherwise, the build is working properly, which is... strange.

That's the logs I got[Nest] 208 - 06/29/2024, 8:43:36 PM LOG [NestApplication] Nest application successfully started +97ms

Jun 29 10:43:36 PM==> No open ports detected on 0.0.0.0, continuing to scan...

Jun 29 10:43:36 PM Application is running on port: http://127.0.0.1:10000

Jun 29 10:43:36 PM

Jun 29 10:43:36 PM> my-app@1.0.1 start /opt/render/project/src

Jun 29 10:43:36 PM> npx nx run api:serve

Jun 29 10:43:36 PM

Jun 29 10:43:36 PM==> Docs on specifying a port: https://render.com/docs/web-services#port-binding

Jun 29 10:43:38 PM==> Your service is live

Jun 29 10:43:42 PM

Jun 29 10:43:42 PM> nx run api:serve:development

Jun 29 10:43:42 PM

Jun 29 10:43:44 PM NX Running target build for project api and 4 tasks it depends on:

Jun 29 10:43:45 PM NX Successfully ran target build for project api and 4 tasks it depends on

Jun 29 10:43:45 PM NX Invalid Cache Directory for Task "@my-app/storage:build"

Jun 29 10:43:45 PMThe local cache artifact in "/opt/render/project/src/.nx/cache/15577062750985043490" was not generated on this machine.

Jun 29 10:43:45 PMAs a result, the cache's content integrity cannot be confirmed, which may make cache restoration potentially unsafe.

Jun 29 10:43:45 PMIf your machine ID has changed since the artifact was cached, run "nx reset" to fix this issue.

Jun 29 10:43:45 PMRead about the error and how to address it here: https://nx.dev/troubleshooting/unknown-local-cache

Jun 29 10:43:45 PMPass --verbose to see the stacktrace.

Jun 29 10:43:45 PMBuild failed, waiting for changes to restart...The error seems to be this one NX Invalid Cache Directory for Task "@my-app/storage:build"But it does not make any senses...


a year ago

You should not be running a development server in a production environment such as Railway, please correct that before proceeding.


jossic
TRIAL

a year ago

I have the same issue, even with production build

> nx run @my-app/core:build

Jun 30 02:27:02 PM

Jun 30 02:27:02 PMCompiling TypeScript files for project "@my-app/core"...

Jun 30 02:27:02 PMDone compiling TypeScript files for project "@my-app/core".

Jun 30 02:27:02 PM

Jun 30 02:27:02 PM> nx run api:build

Jun 30 02:27:02 PM

Jun 30 02:27:02 PM> webpack-cli build --node-env=production

Jun 30 02:27:02 PM

Jun 30 02:27:09 PMchunk (runtime: main) main.js (main) 96 KiB [entry] [rendered]

Jun 30 02:27:09 PMwebpack compiled successfully (56fd10dd84140f1d)

Jun 30 02:27:09 PM NX Successfully ran target build for project api and 4 tasks it depends on

Jun 30 02:27:53 PM==> Uploading build...

Jun 30 02:28:12 PM==> Build uploaded in 10s

Jun 30 02:28:12 PM==> Build successful

Jun 30 02:28:20 PM==> Deploying...

Jun 30 02:29:10 PM==> Using Node version 20.9.0 via /opt/render/project/src/.nvmrc

Jun 30 02:29:10 PM==> Docs on specifying a Node version: https://render.com/docs/node-version

Jun 30 02:29:10 PM==> Using Bun version 1.1.0 (default)

Jun 30 02:29:10 PM==> Docs on specifying a bun version: https://render.com/docs/bun-version

Jun 30 02:29:13 PM==> Running 'cd ../.. && nx run api:serve:production'

Jun 30 02:29:18 PM

Jun 30 02:29:18 PM> nx run api:serve:production

Jun 30 02:29:18 PM

Jun 30 02:29:21 PM NX Running target build for project api and 4 tasks it depends on:

Jun 30 02:29:21 PM NX Successfully ran target build for project api and 4 tasks it depends on

Jun 30 02:29:21 PM NX Invalid Cache Directory for Task "@my-app/storage:build"

Jun 30 02:29:21 PMThe local cache artifact in "/opt/render/project/src/.nx/cache/15577062750985043490" was not generated on this machine.

Jun 30 02:29:21 PMAs a result, the cache's content integrity cannot be confirmed, which may make cache restoration potentially unsafe.

Jun 30 02:29:21 PMIf your machine ID has changed since the artifact was cached, run "nx reset" to fix this issue.

Jun 30 02:29:21 PMRead about the error and how to address it here: https://nx.dev/troubleshooting/unknown-local-cache

Jun 30 02:29:21 PMPass --verbose to see the stacktrace.

Jun 30 02:29:21 PMBuild failed, waiting for changes to restart...

Jun 30 02:29:23 PM==> No open ports detected, continuing to scan...

Jun 30 02:29:23 PM==> Docs on specifying a port: https://render.com/docs/web-services#port-binding

I don't get why there is a cache error, the issue occur only when I change my plan and build the app right after, otherwise, normal build is working..


a year ago

Why am I seeing links to render.com?


jossic
TRIAL

a year ago

Ohh yes indeed I mismatch everything... Sorry, here are my logs on the right failing build. And please don't take into account the previous messages...The begining:Starting Container

╔══════════════════ Nixpacks v1.24.1 ════════════════════════╗

║ setup │ nodejs_22, pnpm-8_x ║

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

║ install │ pnpm i --frozen-lockfile ║

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

║ build │ pnpm install; nx reset; pnpm run build ║

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

║ start │ nx run api:serve:production ║

╚═════════════════════════════════════════════════════╝The end of the logs:

No files changed in this command, skipping snapshotting.

ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH

No files changed in this command, skipping snapshotting.

COPY . /app/.

Taking snapshot of files...

RUN --mount=type=cache,id=-/root/local/share/pnpm/store/v3,target=/root/.local/share/pnpm/store/v3 pnpm i --frozen-lockfile

Cmd: /bin/bash

Args: [-ol pipefail -c pnpm i --frozen-lockfile]

Running: [/bin/bash -ol pipefail -c pnpm i --frozen-lockfile]

 WARN  Ignoring not compatible lockfile at /app/pnpm-lock.yaml

 ERR_PNPM_NO_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is absent

Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"

error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1exit status 1

Stopping ContainerI don't get why it's talking about container, I don't have any dokerfile in my repo, and I can't change nixpack to build the application simply.


a year ago

Railway uses pnpm v8 by default, you are likely using v9, to have railway use v9 also set the packageManager field in your package.json to pnpm@latest

don't get why it's talking about container

Because everything running on Railway is ran in a container.