Next.js 14 Build Fails on Railway with "bun run build" Exit Code 1

yusupsupriyadiHOBBY

3 months ago

I'm encountering an issue deploying my Next.js 14 project on Railway. The build process fails with the following error message:

process "/bin/bash -ol pipefail -c bun run build" did not complete successfully: exit code: 1
This error occurs during the Docker build stage on Railway, specifically when running the bun run build command. The same project builds successfully on my local machine.

Here are some details about my setup:

Next.js Version: 14 (latest)
Package Manager: Bun
Dockerfile: (Please provide your Dockerfile here)
Railway Project URL: (Please provide the URL of your Railway project)
I've already tried the following troubleshooting steps:

Ensured all dependencies are correctly listed in package.json and are compatible with the Railway environment.
Regenerated the bun.lockb file.
Checked for any missing or incorrect environment variables.
Reviewed the Railway build logs for more detailed error messages (please see attached screenshots/logs).
Tried simplifying the Dockerfile to isolate the issue.
I'm using caching in my Dockerfile with the --mount command for both the Next.js cache and the node_modules cache. Here's the relevant part of my Dockerfile:

Dockerfile

RUN --mount=type=cache,id=s/next-cache,target=/app/.next/cache \
--mount=type=cache,id=s/nodemodules-cache,target=/app/nodemodules/.cache \
bun install --frozen-lockfile && \
bun run build
Despite these efforts, I'm still unable to resolve the build error. Could you please assist me in identifying the root cause of this issue and provide a solution?

Thank you for your time and support.

View Deploy details

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

0 Replies