Running a Bun + pnpm Application on Railway
Hi!
I have a monorepo where I use pnpm + turborepo for repo & package managment. One of the apps in the repository, a discord bot, uses bun as its runtime, but still uses pnpm for the actual package installation. Any idea how I can go about getting this working w/ nixpacks / railway? Thanks!
Solution:Jump to solution
or just use 1.0.23 on railway, add
nixpkgsArchive = 'e99651a836b162b48fbf4195e0c8d3028b6b32a8'
below your [phases.setup]
54 Replies
Project ID:
bc172a5f-caaa-4872-a59d-62201654b4f6
bc172a5f-caaa-4872-a59d-62201654b4f6
I'd probably go about writing a custom nixpacks plan for that specific app where I would have a file like
bot.nixpacks.toml
with all the applicable configurations https://nixpacks.com/docs/configuration/file
and then the NIXPACKS_CONFIG_FILE
service variable set to name of my nixpacks file so that the custom build plan is only used for the bot servicesGot it, so would I want the nixpacks file to be at the root of the repo?
correct
Also, I am new to nixpacks config stuff. Does this seem like a good starting point?
Not really sure how my custom root for the service comes into play here
![No description](https://cdn.answeroverflow.com/1206994937376149574/image.png)
does any of the code in that folder access code outside of that folder? aka a shared monorepo
Yes, it accesses some shared packages in the
/packages/
directoryyeah looks decent, replace with the applicable bun build and start commands, also add an install phase with the applicable bun command
then setting the root directory to what you have would only copy in what's in that set directory meaning your bot code can't import something from directories elsewhere, it would need to be set to the root directory and that's where your custom
bot.nixpacks.toml
would liveGot it got it, have went ahead and done that, running into the following error during build:
![No description](https://cdn.answeroverflow.com/1206996192899235900/image.png)
I thought you wanted to use bun for the install, build, and start commands, looks like you're still using pnpm there.
for your install, build, and start commands in the custom build plan you would need to use commands that run in a set directory, so that for example your install command only installs the packages that the bot app requires
Yep, sorry for the miscommunication! I am only using bun for a runtime.
Currently I now have the service root set as just the root of the monorepo. Are you saying that
pnpm install
in the root would not work? On my local machine, pnpm handles monorepo stuffs so running pnpm install
at root installs for all packages & apps.okay only bun for runtime but pnpm for package management, got it!
yes pnpm install ran in the root will install all packages for all apps, but we only want to install the packages the bot needs, pnpm provides an applicable flag or argument of some sort to do such a thing but I don't know it off the top of my head
I can't find the command for chaining multiple packages / apps together in one command, but giving this a shot