R
Railway9mo ago
DivMode

Bun with turborepo support

Hey guys, Just switched over to bun from fastify but having some trouble setting it up properly to work with railway. Im using turborepo and I just want railway to build the elysia app and I added the nixpacks.toml to root. The nextjs app itself is using vercel. Here is the github repo: https://github.com/DivMode/turbo-test railway server: 4392cf24-3b39-4f8b-a38b-2a47273c234b
[phases.setup]
nixpkgsArchive = 'd68b3b0c914aea10eee7cf2e59ef44e39bc221c9' # https://github.com/NixOS/nixpkgs/commit/d68b3b0c914aea10eee7cf2e59ef44e39bc221c9

[phases.build]
cmds = []

[start]
cmds = ["pnpm run start --filter server"]
[phases.setup]
nixpkgsArchive = 'd68b3b0c914aea10eee7cf2e59ef44e39bc221c9' # https://github.com/NixOS/nixpkgs/commit/d68b3b0c914aea10eee7cf2e59ef44e39bc221c9

[phases.build]
cmds = []

[start]
cmds = ["pnpm run start --filter server"]
GitHub
GitHub - DivMode/turbo-test: Testing turborepo
Testing turborepo. Contribute to DivMode/turbo-test development by creating an account on GitHub.
19 Replies
Percy
Percy9mo ago
Project ID: 4392cf24-3b39-4f8b-a38b-2a47273c234b
Brody
Brody9mo ago
for starters, it looks like you are missing a bun lock file, bun won't be automatically detected without a bun lock file
DivMode
DivMode9mo ago
I added the bun.lockb file to root and tried it inside the server but no luck with getting it to work
Brody
Brody9mo ago
you have yet to tell us what isn't working
DivMode
DivMode9mo ago
"server:start: sh: 1: bun: not found" it also trys to start the nextjs app but I do have in the nixfile
cmds = ["pnpm run start --filter server"]
cmds = ["pnpm run start --filter server"]
Brody
Brody9mo ago
ah gotcha, you still have a pnpm lock file, so node is still being detected
DivMode
DivMode9mo ago
-----
> [stage-0 6/9] RUN --mount=type=cache,id=s/4392cf24-3b39-4f8b-a38b-2a47273c234b-/root/bun,target=/root/.bun npm install -g corepack && corepack enable:
0.340 /bin/bash: line 1: npm: command not found
-----

Dockerfile:20
-------------------
18 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH
19 | COPY . /app/.
20 | >>> RUN --mount=type=cache,id=s/4392cf24-3b39-4f8b-a38b-2a47273c234b-/root/bun,target=/root/.bun npm install -g corepack && corepack enable
21 | RUN --mount=type=cache,id=s/4392cf24-3b39-4f8b-a38b-2a47273c234b-/root/bun,target=/root/.bun bun i --no-save
22 |
-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm install -g corepack && corepack enable" did not complete successfully: exit code: 127

Error: Docker build failed
-----
> [stage-0 6/9] RUN --mount=type=cache,id=s/4392cf24-3b39-4f8b-a38b-2a47273c234b-/root/bun,target=/root/.bun npm install -g corepack && corepack enable:
0.340 /bin/bash: line 1: npm: command not found
-----

Dockerfile:20
-------------------
18 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH
19 | COPY . /app/.
20 | >>> RUN --mount=type=cache,id=s/4392cf24-3b39-4f8b-a38b-2a47273c234b-/root/bun,target=/root/.bun npm install -g corepack && corepack enable
21 | RUN --mount=type=cache,id=s/4392cf24-3b39-4f8b-a38b-2a47273c234b-/root/bun,target=/root/.bun bun i --no-save
22 |
-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm install -g corepack && corepack enable" did not complete successfully: exit code: 127

Error: Docker build failed
Getting this after removing the lockfile but is there a way I can have bo the the pnpm lockfile and use bun?
Brody
Brody9mo ago
you want to use pnpm instead of buns package manager? I'm sorry but I don't see the point in that? what is your usecase for using bun in the first place?
DivMode
DivMode9mo ago
esm and commonjs compatability, was having some trouble with it in fastify, I just want to use bun with elysia as the backend on railway and nextjs app in the frontend with vercel
Brody
Brody9mo ago
then the backend being part of the turbo repo is probably only hindering the deployable of this repo
DivMode
DivMode9mo ago
I was hoping to keep everything inside the monorepo. Im assuming that isnt possible at this time?
Brody
Brody9mo ago
you can still do a monorepo, but an isolated monorepo would probably work much better for this type of thing
DivMode
DivMode9mo ago
Would love to get it working with turborepo on railway as it simplifies things for me but I guess support for bun isnt really there yet.
Brody
Brody9mo ago
to be honest I don't think you will ever be able to just no config deploy this repo how you have it now with pnpm mixed in with bun, that's why I suggested an isolated monorepo
DivMode
DivMode9mo ago
I guess your right, one thing I really liked about the monorepo approach was I could easily share the database schemas and types between frontend and backend.
Brody
Brody9mo ago
yeah but you are mixing technologies
angelo
angelo9mo ago
Yea, @divmode - sans addtl. Railway features, there wouldn't be a way for us to automatically detect it as you are still pinning some deps via pnpm and cJS. Unless you are giving us a custom build script that you have yourself to rectify the difference, you will need to beat Nixpacks into shape or use a Dockerfile
Brody
Brody9mo ago
beautifully said
DivMode
DivMode9mo ago
Using a dockerfile to try and get this to work sounds interesting, ill take a look into it, appreciate your guys input
Want results from more Discord servers?
Add your server
More Posts