Railway Metal builder fails Docker npm run build but does not retain underlying build output
somgurung
HOBBYOP

an hour ago

Hi Railway Support,

I'm having a persistent build problem with an existing production service. The application builds successfully from the exact committed source locally, but Railway's Metal builder repeatedly fails during the Docker build and does not retain the underlying compiler output.

Project ID: 0f07d0db-6bb7-4603-80c3-817b3f09f29b

Service: marketing-api

Service ID: 6fa8a8a2-1b59-4122-b792-6f1682b34adf

Environment: production

Latest failed deployment: 0bd4bf2d-2a6a-4d54-9431-edab11a2bff6

Last successful deployment: 12cf8b4f-6beb-4c66-aeff-c78c0adf7f0b

The latest Railway build reports only:

Build Failed: build daemon returned an error < failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1 >

The retained build logs contain no npm/TypeScript compiler output—only that error and Metal-builder scheduling messages.

The source is a clean Git commit:

65b66a05ad7396b6459eddf62b33abf8acff5241

I have verified from a clean detached worktree:

npm ci passes.

npm run build (tsc) passes.

The Railway CLI upload selection was reproduced locally and required source files are present.

An isolated directory containing exactly the Docker build-stage inputs (package*.json, tsconfig.json, src/, database/) passes npm ci && npm run build.

No .dockerignore is removing application source.

Required dependencies are present in the committed lockfile.

A tracked Docker build marker was added immediately before RUN npm run build to invalidate the build layer, but the fresh Railway build still fails identically.

The service currently uses the Dockerfile builder with /Dockerfile, and the controlled local upload uses the backend directory as the source root.

Recent failed deployments include:

0bd4bf2d-2a6a-4d54-9431-edab11a2bff6

250d5c1b-1d67-4295-9f95-b459ef48b96c

7984cdc2-6805-4f85-ba67-7a099dfa71c4

da08a329-6c11-483e-ad3f-db8c5213fd63

Could you please inspect the remote Metal-builder/BuildKit logs for deployment 0bd4bf2d-2a6a-4d54-9431-edab11a2bff6, particularly the full stdout/stderr from the RUN npm run build layer?

I'd also appreciate confirmation whether there is a builder/snapshot/cache issue affecting this service, since the CLI-visible build logs are not exposing the actual compiler failure.

The previous successful production deployment remains online, so I have stopped further deployment attempts while this is investigated.

Thank you.

Solved$10 Bounty

6 Replies

Railway
BOT

an hour ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway about 1 hour ago


an hour ago

Can you share the Full Build Logs here?


somgurung
HOBBYOP

an hour ago

Yes — I found the full Build Logs in the Railway dashboard. This is the complete TypeScript error from the latest failed build:

backend@1.0.0 build

tsc

src/app.ts(44,42): error TS2307: Cannot find module './infrastructure/storage/storageService.js' or its corresponding type declarations.

src/modules/businessBrain/assets/assetService.ts(15,30): error TS2307: Cannot find module '../../../infrastructure/storage/storageService.js' or its corresponding type declarations.

src/modules/businessBrain/assets/assetUploadController.ts(14,8): error TS2307: Cannot find module '../../../infrastructure/storage/storageService.js' or its corresponding type declarations.

src/modules/email/emailImageAssetService.ts(3,30): error TS2307: Cannot find module '../../infrastructure/storage/storageService.js' or its corresponding type declarations.

Build Failed: build daemon returned an error < failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1 >

The unusual part is that src/infrastructure/storage/storageService.ts is present in the clean committed source and the same clean source passes npm ci && npm run build locally.

We also reproduced the Railway CLI upload file selection locally and confirmed src/infrastructure/storage/storageService.ts is included.

Please let me know if you need any other part of the build log or Dockerfile.


an hour ago

Do you have root directory configured on your service?


somgurung
HOBBYOP

an hour ago

I added temporary non-secret diagnostics immediately before npm run build, and this exposed the issue. Inside Railway's actual Docker build container, src/infrastructure/storage/ is completely absent, even though it is committed and present in the clean local source.

The build shows:

=== DIAGNOSTIC: src/infrastructure ===

jobs/

security/

=== DIAGNOSTIC: src/infrastructure/storage ===

ls: src/infrastructure/storage: No such file or directory

So the TypeScript error occurs because that source directory is missing from Railway's effective Docker build context. I'm now investigating Railway CLI upload/ignore behavior. If you know why a tracked directory could be omitted from the uploaded snapshot, that would be very helpful.


somgurung
HOBBYOP

an hour ago

Yes, it was configured with /backend earlier. During troubleshooting we cleared the Root Directory because we are deploying ./backend directly with railway up --path-as-root.

We have now identified and fixed the issue: Railway's upload was excluding src/infrastructure/storage/. Adding a backend .railwayignore rule to explicitly include that source directory fixed it.

The latest API deployment now builds successfully and is running in production. The worker and frontend have also deployed successfully.

Thank you for your help.


somgurung
HOBBYOP

43 minutes ago

resolved


Status changed to Solved mayori 29 minutes ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...