Switched back to bun as package manager, do I still need it in nixpacks.toml?
This is my current nixpacks toml, previously I was using npm because of a fatal bun bug with turborepo, but Jarred help me with a fix (and it'll be prevented going forward in 1.0.15).
Do I still need to explcitly declare bun as a nixPkg in my nixpacks.toml? I think I can remove it, but if I remember correctly, the default is an older version of Bun.
Is there a way I can always use latest?
330 Replies
Project ID:
N/A
N/A
Do I still need to explcitly declare bun as a nixPkg in my nixpacks.toml?as long as your only lock file is a bun lock file, then bun will be detected automatically
I think I can remove it, but if I remember correctly, the default is an older version of Bun.the
nixpkgsArchive
thing solves that, so dont remove the archiveI see, is there a way to always get latest though, rather than having to update the nixpkgsArchive version?
there is not
thats unfortunately the only way to specify package versions
what version would it fallback to if the archive weren't specified?
i think 1.0.11
3 minor versions behind i think?
gotcha, I'm not super familar with github actions, but is this something that could be solved by them? having some kind of script look up the latest nixpacks commit and update my file to the latest?
Bun's minor releases are really helpful in solving bugs so I try to stay on canary, but would like to automate it so I don't have to update it each time
nix packages doesnt even have the latest right now
https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/web/bun/default.nix
wait
i may have an idea
@luna - that bun command that updates itself, can that be run as a phase in a nixpacks.toml? (unzip is easy to add)
cant hurt to try this?
add a print to your app to print the bun version
building rn
i can report success on upgrading but we may have a new bug
damn glibc thing coming back to haunt us
long shot, updated this
no luck
btw i cant see your project, i dont work for railway
cant see a reason why not
thats just missing openssl, no?
š® i totally thought conductors did
mb š
haha nope, that would be a very big security concern
I have it though?
possibly related https://github.com/oven-sh/bun/issues/5534
GitHub
version `GLIBC_2.18' not found Ā· Issue #5534 Ā· oven-sh/bun
What version of Bun is running? idk i cant run it What platform is your computer? Linux 3.10.0-1160.88.1.el7.x86_64 x86_64 x86_64 What steps can reproduce the bug? Install Bun curl -fsSL https://bu...
confused because I don't get this issue when not running the upgrade command
okay seems those people are actually outta date
@Brody what os is nixpacks run on?
This works without said issue
was just trying to find a way to stay on latest
ubuntu 22 maybe, i forget
dockerfile?
try this
then we move to dockerfile
I looked into it, wouldn't be too hard especially now that I no longer use npm
there should be a way todo this via nixpacks but yeah if you get stuck a docker file would be fine to use
i dont believe it would be hard at all to do with a dockerfile
incase i get busy and you dont have a copy
https://raw.githubusercontent.com/ImLunaHey/hunter/main/Dockerfile
main thing I haven't done before is turborepo pruning for dockerfiles but they have a good guide
well i dont think railway runs a prune, so dont worry about it
turbo prune docs --docker
then copy that instead of src
but youre also using bun so you may not need it?oh just because it's much faster?
yep
hey!
i think that worked!
oh wait
false alarm
was looking at an old build?
lol
alrighty time to make a Dockerfile
<:sunglasses_1:767749456648339497>
is that error in the build or deploy phase?
deploy
only shows when running
dockerfile time!
are you familar with dockerfiles by any chance?
do you know what version gets pulled from this command
latest
i think
latest is correct
digest matches
gotcha, do you know if the copy package.json here would copy my turborepo root one or just based on the folder?
oh hmm the bun lock file is at root
put the dockerfile at the root
uh, I don't think that'd be correct though?
it'd mess with my vercel deployment
I think
my understanding was to modify the settings on railway to get the dockerfile inside the app, so that it only affects that app and I can have other dockerfiles for other apps
you have railway building from the root right?
no, I don't, I have it only build on that app
it's filtered down
but whats your root directory set to in your service settings?
oh hmm
there is a way to change dockerfile location though i believe
then the dockerfile needs to be at the root, you can create a
Dockerfile.rlwy
at the root as to not mess with anything, and then set a RAILWAY_DOCKERFILE_PATH
service variable to the name of your dockerfilei see, it has to be at root?
yeah you need to copy stuff from the root into the image, like the lock file
you dont need to copy the apps you arent going to be using though
wait, I'm a little confused
I feel like it'd be annoying to have multiple app's worth of Dockerfiles at the root level, so wouldn't it be better for the Dockerfile to be in my app's folder and I set the env variable to that path, even though it's still executing from root?
your bun lock file is in the root, and your package.json is also in the root, you need those things in the image, thus your dockerfile needs to be in the root
the docker file is being executed from root right?
but I don't it needs to be saved there if you set the env_var to it's actual path
so you could still have it transfer over the bun lock file and such
what do i know (not much), try it lol
i geninunely don't know either am just trying to piece things together
cant hurt to try
this racks my brain though
trying to merge these instructions from turborepo to bun
start with something simple like luna's dockerfile
i copied the one from bun's site and am trying to modify it to work with turborepo pruning
copy in everything, you dont need to complicate things with multistage
just get it working first, dont worry about anything fancy
itās better to have a working dockerfile thatās huge than a non working smaller one. š
i have an idea
praying to the ai gods
lol
does nixpacks handle port stuff?
just realized I never had to map my port 3001 to port 80 or anything on nixpacks
ah i see
so nixpacks just does 80 am guessing
nothing to do with nixpacks, railway makes a random PORT variable available, then maps that to 443 externally
how do I handle that in my dockerfile?
with the expose
you donāt need todo anything in the dockerfile. in your app just listen on the process.env.PORT
oh so I don't need to expose anything in the dockerfile?
yep, what Luna said, no need for expose
interesting, i don't get how that works but I'll trust y'all. like doesn't the container block networking unless you expose?
nope
oh, that seems, bad?
expose works more like āhey docker this is where things will beā youāre always free to open any ports you want even if the dockerfile doesnāt say itās using them.
in this case we know by convention itāll be using the port thatās set in the env.
plus the containers are isolated
keep in mind a dockerfile describes the container image. it doesnāt do anything outside of the image. so expose for example is just a notice to docker.
interesting, I'm guessing that applies to env vars I have in railway too?
where I don't need to put them in the dockerfile
yeah i dont list any of mine.
https://docs.docker.com/engine/reference/builder/ docs are good
Docker Documentation
Dockerfile reference
Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more.
that depends though, if you need a variable during build then you do have to bring it in with the ARG keyword.
also a good post on this for when EXPOSE does get used. https://we-are.bookmyshow.com/understanding-expose-in-dockerfile-266938b6a33d?gi=d6f0748c150a
Medium
Understanding āEXPOSEā in Dockerfile
Docker has revolutionised the way we build apps. To start using docker and building docker images, the only thing we need is a Dockerfileā¦
good point
yeah thereās also build vs runtime envs
thanks! will be digging into these more as i finally piece this all together (rather than doing the smart thing and just doing something simple)
(my hope is that i suffer through this once and then can forget about it)
is where I'm at so far
currently debugging
avoid using global install use
npx
instead
or bunx
will do! why?
there's almost no upside to using a global that i can think of, npx and such kinda fixed the issue global was trying to solve.
the cons of global are issues like the above problem š
and then you've got versions clashing, etc.
so this instead?
so many things to learn
oh
welp
did all this work
for nothing
haha told you to not worry about all that and just get it working first
you were my attempt to be optimal
i was sub-optimal
KISS
i already went down the wrong path for this at the start by choosing Bun
Bun is great
but also
i now know why it's called the bleeding edge nixpacks use docker in the middle (like could you see a dockerfile it generates?)
nixpacks does generate a dockerfile
hmm
i might just give up for now and go back to just using nixpacks and manually updating bun whenever it does
seems easier
just write the simple dockerfile like ive been saying
working on itā¢ļø
currently undoing all the other stuff and trying to keep it simple
need to also figure out the openssl issue
there shouldnt be an openssl issue when using the bun image?
oh nice
famous last words
in every programmer there are two wolves
the "i want it optimal" wolf
and the
"i want it working" wolf
thats fine as long as the "i want it working" wolf gets to drive first
yes, am currently trying to figure out environment variables now
because prisma needs them to
ty
wait
it's so cursed
hmm
maybe I don't do bun install from root level
very much no
?
dont mess around with multiple stages
ah, i copied those from the bun example, will remove them
you arent copying files between the stages, so it wont work
does nixpacks just put a ton of ARG commands in it's dockerfile then?
yes lol
š
dont do this yourself tho
nixpacks does this since it has no way of knowing what variables the users code will need at build, but you do know what your code needs
i think I just need this for prisma's postinstall step that generates the client
which is kind of redundant since the turbo run build step does the postinstall prisma stuff anyways... but
gonna get it working first
you dont need to assign an arg to an env
why does nixpacks do it?
heck if i know, all i know is line 8 is not needed
good
why cd into ws_server?
doesnt turbo have some kind of command to install deps for a specfic app?
my thinking was that bun just installs the entire project if i don't, and that's bad cause there are a ton of env vars i don't want to have to account for
right so isnt there a way to install packages for a specfic app, without cd
i don't think there's a turbo wrapped command for installing deps?
you cd into that folder and then never cd back out
do you need to? for some reason i thought it was scoped to it's own command
but i guess that's me thinking about the stages
does bun have a way to install deps from a package in a subfolder? i think you should avoid using cd
huh? just add cd to the end
that's how half my production Dockerfiles are written š
idk just sounds yucky to me, cd'ing around
š¤·āāļø most production code is held together with duct tape it is what it is
right now i still can't figure out what environment variable is causing it not to install lmao
i think my .env might be being copied in the copy . . command? guessing i should add it to dockerignore?
am testing locally rn
oh wait i already have it
this do be odd
how many service variables you got?
where is the error being thrown..? š¤
any chance you can do this locally instead of railway?
i am testing locally
i test all mine locally before pushing
if you run those exact commands locally OUTSIDE of docker..?
ah haven't tried that yet, but I think bun would use my .env
i do outside of docker -> inside of docker -> railway for my testing
i bet you'll see more of an error message if you can get it to error outside of docker
the error message looks like the
new URL()
thing isnt happya decent amount
cool
I think i got it all
the last step fails because I don't export my .env
but I think it should work on railway now
railway up
timegithub push š
i test on main
haha nice
i was wrong
bring all the variables into the dockerfile lol
well so, i tested all the commands locally and they work now
it's only on railway do i get prisma undefined issue
such a useful error message
I tried replacing the command with bun prisma generate, but that didn't help
your database url variable, is it a public or private url?
public in that it has user/pass in it
all database urls do lol
ah
still public i'm guessing? it's on neon db
ah then yeah definitely public
and i don't limit it
print all the variables with printenv?
in the dockerfile?
yeah
direct and database url are both there as intended
my only guess is it's something with the way I call prisma? but I tried bun prisma generate and same issue?
I guess I could try bunx prisma
i could also skip the build step cause prisma should already be creating a client when it gets installed
strange that it would fail on the turbo run build
this is indeed weird
i removed the turbo build command and the build completes without error
773MB image
does the app run tho haha
time to find out
no
no it does not
ahhh need to do bunx turbo
you should set the start command in the dockerfile instead
i think I do?
with CMD
oh
and in shell format
aka not in an array
User bun killing me here i think
oh yes, don't switch users
what's the difference?
I forget what the array syntax is, but not using the array means it's run in the shell
you could try CMD with the array, that can't hurt
something's still broken and I don't know what
thank you all for the help by the way, extremely appreciated
y'all are thebest
very tempted to just switch back to nixpacks at this point though
why did nixpacks kinda work tho
this is what i'm confused about
we may never know
how can I get the dockerfile that nixpacks creates via railway?
the dockerfile is available inside the image
I forget the path unfortunately
https://nixpacks.com/docs/install
you could build your app locally with nixpacks then look through the image layers for it
but it uses nix, so it's likely only gonna complicate things more
You can run Nicpacks locally and produce an image!
Getting full context
š¤£
Hello from Twitter
Angelo saw me declare defeat on twitter and wanted to help
youre in better hands now
you and luna were pretty amazing hands though so thank you again
So- real quick, can you get to a state where you had a working local image?
In the meantime, I am looking (read: stealing) at bun references from other users and Jarrod himself
I'm still getting this (which doesn't appear on railway) so my guess is it's to do with env/args but I have the only two I thought could cause it (prisma direct url and database url)
next step would be to copy every variable I have on railway as a build arg on my dockerfile so might try that next
on railway though, when it builds it doesn't get this error but goes further along and instead gets a prisma: undefined error, which is very unuseful to debug this lol occurs in my turbo run build --filter=ws_server command
Can you share to me:
- folder structure
- package file
- dockerfile
TURBO
want read access to my repo?
okay, this narrows down some styff
might be easier than copying here
Why the hell not: [email protected]
Grabbing my laptop one sec
https://github.com/StarlightLabsCo/bonfire/invitations
omg, ty
i thought u were already on it
Angelo voice I'm in
I doomscroll Twitter for the holidays
i pushed the bare minimal dockerfile on a new branch called... wait for it..
I presume the
dockerfile
branch is the one I should be working in?yeah, the only real change is I deleted the nixpacks (currently deployed & working)
and added the dockerfile
the start of all this is I just want a way to stay on bun canary lmao also doing turborepo prune in dockerfile before I learned that it doesn't support bun yet
so switched to doing bare minimum dockerfile first
gotcha- yep, so I think JR has a fix for this upcoming for Nixpacks, the Bun team moves really fast (great) and we are hiring someone full time for builds so unfortunately, the experience has fallen off the wayside
anyway, lemme solve the dockerfile, log the issue, and we can send you on your marry way
they go zooooom
5 min, going to bang head for a bit
question, what are the shared pkgs that you need from Turbo?
I think I got it @Harris
doing some final testing for ya, was a
cd
issue as expected
I think I wrote an internal spec somewhere where we can let you step into the docker file tree
This was like Top 3 issues with my Dockerfiles
okay- bun workspace error, but that is solvable, one secOhhh
ā¤ļø
Project ID on Railway?
I can add myself to a staging env (and will send credits) to test
railway up
Sorry got pulled away
Back now
Thank you so much for looking into this
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
what was the issue?
so your Dockerfile isn't at the root of your project, it's in the
ws_server
so Bun doesn't have monorepo context
I am hoisting everything up
Perfect world- you'd be able to stay on Nixpacks
okay- now I need the env vars, do I have your permission to temp. add myself as a project member?go for it! š«”
I ask because I don't wanna fail our audit of the SoC2 audit
Security requirement
makes me trust y'all even more š
i'm still a little confused in regards to the dockerfile though, my understanding was that the file would be located there but executed from a root context since that's whats specified in the settings
if that really is the problem or one of the problems, remember what I said š
The settings is wrong š
When you have a Dockerfile, the docker build context reigns supreme
ohhh wait
locally i was doing -f
(this is why we are hiring ;-;)
It applies only to nixpacks, so for monorepo Dockerfile, you want to host the file at root
hehe that's that I suggested, I'm smort
bun is looking for workspace deps that can't resolve at that folder
but since the bun team are busy creating a new PSQL driver, the errors in dockerfile aren't fleshed out
u were right
this is a classic rake skating exercise
only advanced rake skaters can solve this (possible)
what are your parents feeding you
YES
favorite meme
love them but am confused at their dev pipeline sometimes
am v excited for a fix coming in 1.0.15 that fixes a workspace dep bun that I was confused by and then hopefully more reliabile websocket clients by end of dec
so just to understand properly
1.) i was trying to be fancy by having dockerfile in each app rather than root level
2.) docker build was taking the context from the dockerfile and then just going ???
Yes
and it's a bun thing specifically?
no (yes)
Okay, now resolving the railway specifc error, > [6/6] RUN bunx prisma generate:
1.508 Error: undefined
this is US
ugh
OH wait, so this was the bun specific one?
or just something else
what's the tell?
(one sec, gf called)
back
Okay- so
bunx prisma generate
needed Node in the container ;-;
Okay- now testing deploywelp that explains why nixpacks worked?
Yep- JR's multi-lang detection resolution is goated as the kids say
found a bug, we don't allow an
up
deploy if watch paths are enabled... ohh
i see
this is insanely non-obvious
had to GH issue splunkel to find the solution to that
TIL
thats so funny to me
previously i had issues because i was trying to use npm as my package manager and nixpacks detected bun (because of turbopack issues)
and now the opposite
lol
Jerred and I will be having a... talk
Will tell Railway to use the container start, one sec
question, why is that invalid anyway
I dunno
You can accuse the Railway team for many shortcomings, honesty isn't one of them
very true
this whole process has been very frustrating, lots of good learnings from this- I would have rage quit and moved to Render, then rage quit and stood up EKS
is bunx prisma generate usually just a shim to npx?
is that why it had an issue
I think so
turbo fun...
lemme see here, will bang it to shape
is supposed to cover that one
wait yea
ez fix, one sec
CMD [ "bunx", "turbo", "run", "start", "--filter=ws_server" ]
is this the intended command?i believeso
not super familar with cmd syntax
Railway
404 - Page not found
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
live
can you throw some requests there?
lemme spin up a local project and change the backend url
not project
but just
running it lol
https://bonfire-united-orange.up.railway.app/
seems like normal behavior!
nice!
ty
ty ty ty
so to summarize changes
- need node to do prisma generate
- dockerfile doesn't like it when it's not at root
- some bun thing?
Yes
My file tree:
you're the best
ty
no u for picking Railway
Happy Belated Thanksgiving!
you as well!
also massive thanks to @luna and @Brody- they deserve the credit as well š¤
@Angelo two last questions, the dockerfile shouldn't mess with anything else right like my nextjs app or anything?
that was my original concern and why I wanted to put it in the subfolder, not knowing it'd cause a lot of issues lol
to make it use the container start do i just leave that setting blank?
Yep
i dont know the answer but i am curious especially based on https://twitter.com/leeerob/status/1727380301054349441
You are hosting this on vercel? I don't think it should interfere
This is a revamp of Zeit Now if you remember
back when Vercel were called Zeit
before i knew about it
i only knew it was called Zeit because a founder I know created Zeet in response
and he had to explain it to me lol
ah
we will see that world with railway
Johnny is cool person! (Zeet)
All aboard! chugga chugga chugga
š
zoom
what issue would i need to watch if i wanted to change it in the future? is it a bun thing
for example if i had another docker app in that same monorepo
so, if you can for me, can you trigger a vercel PR deployment? I don't think it should interfere
just did
no issue
vercel looks for a
turbo.json
at the root so that seems to be finebut I guess I was asking more generally, lets say I add another backend app that uses docker
is that just not possible with how bun handles things rn?
to have it not at root
you would just make a new Dockerfile at root and filter the same way you did with ws
Railway can point to a specific dockerfile
gotcha so that solves the issue completely then
pog
although ocd me really wants to put them in subfolders
just give them nice names
I'll name Dockerfile.Tim and