R
Railwayā€¢13mo ago
Harris

Switched back to bun as package manager, do I still need it in nixpacks.toml?

[phases.setup]
nixpkgsArchive = 'f53263caceb5f2a92eb2269e8eed9ef7a065fb7a' # https://github.com/NixOS/nixpkgs/commit/f53263caceb5f2a92eb2269e8eed9ef7a065fb7a
nixPkgs = ['...', 'bun']
nixLibs = ['...', 'openssl']
[phases.setup]
nixpkgsArchive = 'f53263caceb5f2a92eb2269e8eed9ef7a065fb7a' # https://github.com/NixOS/nixpkgs/commit/f53263caceb5f2a92eb2269e8eed9ef7a065fb7a
nixPkgs = ['...', 'bun']
nixLibs = ['...', 'openssl']
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
Percy
Percyā€¢13mo ago
Project ID: N/A
Harris
HarrisOPā€¢13mo ago
N/A
Brody
Brodyā€¢13mo ago
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 archive
Harris
HarrisOPā€¢13mo ago
I see, is there a way to always get latest though, rather than having to update the nixpkgsArchive version?
Brody
Brodyā€¢13mo ago
there is not thats unfortunately the only way to specify package versions
Harris
HarrisOPā€¢13mo ago
what version would it fallback to if the archive weren't specified?
Brody
Brodyā€¢13mo ago
i think 1.0.11 3 minor versions behind i think?
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
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)
[phases.setup]
nixPkgs = ['...', 'bun', 'unzip']
nixLibs = ['...', 'openssl', 'zlib']

[phases.upgrade]
dependsOn = ['setup']
cmds = ['bun upgrade --canary']
[phases.setup]
nixPkgs = ['...', 'bun', 'unzip']
nixLibs = ['...', 'openssl', 'zlib']

[phases.upgrade]
dependsOn = ['setup']
cmds = ['bun upgrade --canary']
cant hurt to try this? add a print to your app to print the bun version
Harris
HarrisOPā€¢13mo ago
salute building rn
Harris
HarrisOPā€¢13mo ago
i can report success on upgrading but we may have a new bug SweatCat
No description
Harris
HarrisOPā€¢13mo ago
No description
Brody
Brodyā€¢13mo ago
damn glibc thing coming back to haunt us long shot, updated this
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
no luck
Brody
Brodyā€¢13mo ago
btw i cant see your project, i dont work for railway
luna
lunaā€¢13mo ago
cant see a reason why not thats just missing openssl, no?
Harris
HarrisOPā€¢13mo ago
šŸ˜® i totally thought conductors did mb šŸ˜…
Brody
Brodyā€¢13mo ago
haha nope, that would be a very big security concern
Harris
HarrisOPā€¢13mo ago
I have it though?
No description
luna
lunaā€¢13mo ago
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...
Harris
HarrisOPā€¢13mo ago
confused because I don't get this issue when not running the upgrade command
luna
lunaā€¢13mo ago
okay seems those people are actually outta date @Brody what os is nixpacks run on?
Harris
HarrisOPā€¢13mo ago
[phases.setup]
nixpkgsArchive = 'f53263caceb5f2a92eb2269e8eed9ef7a065fb7a' # https://github.com/NixOS/nixpkgs/commit/f53263caceb5f2a92eb2269e8eed9ef7a065fb7a
nixPkgs = ['...', 'bun']
nixLibs = ['...', 'openssl']
[phases.setup]
nixpkgsArchive = 'f53263caceb5f2a92eb2269e8eed9ef7a065fb7a' # https://github.com/NixOS/nixpkgs/commit/f53263caceb5f2a92eb2269e8eed9ef7a065fb7a
nixPkgs = ['...', 'bun']
nixLibs = ['...', 'openssl']
This works without said issue was just trying to find a way to stay on latest
Brody
Brodyā€¢13mo ago
ubuntu 22 maybe, i forget
luna
lunaā€¢13mo ago
dockerfile?
Brody
Brodyā€¢13mo ago
try this then we move to dockerfile
Harris
HarrisOPā€¢13mo ago
I looked into it, wouldn't be too hard especially now that I no longer use npm
luna
lunaā€¢13mo ago
there should be a way todo this via nixpacks but yeah if you get stuck a docker file would be fine to use
Brody
Brodyā€¢13mo ago
i dont believe it would be hard at all to do with a dockerfile
luna
lunaā€¢13mo ago
Harris
HarrisOPā€¢13mo ago
main thing I haven't done before is turborepo pruning for dockerfiles but they have a good guide
Brody
Brodyā€¢13mo ago
well i dont think railway runs a prune, so dont worry about it
luna
lunaā€¢13mo ago
turbo prune docs --docker then copy that instead of src but youre also using bun so you may not need it?
Harris
HarrisOPā€¢13mo ago
oh just because it's much faster?
luna
lunaā€¢13mo ago
yep
Harris
HarrisOPā€¢13mo ago
hey!
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
i think that worked! oh wait false alarm was looking at an old build?
Brody
Brodyā€¢13mo ago
lol
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
alrighty time to make a Dockerfile <:sunglasses_1:767749456648339497>
Brody
Brodyā€¢13mo ago
is that error in the build or deploy phase?
Harris
HarrisOPā€¢13mo ago
deploy only shows when running
Brody
Brodyā€¢13mo ago
dockerfile time!
Harris
HarrisOPā€¢13mo ago
are you familar with dockerfiles by any chance?
Harris
HarrisOPā€¢13mo ago
do you know what version gets pulled from this command
No description
Harris
HarrisOPā€¢13mo ago
FROM oven/bun:1 as base
FROM oven/bun:1 as base
luna
lunaā€¢13mo ago
latest i think
Brody
Brodyā€¢13mo ago
latest is correct digest matches
Harris
HarrisOPā€¢13mo ago
gotcha, do you know if the copy package.json here would copy my turborepo root one or just based on the folder?
No description
Harris
HarrisOPā€¢13mo ago
oh hmm the bun lock file is at root
Brody
Brodyā€¢13mo ago
put the dockerfile at the root
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
you have railway building from the root right?
Harris
HarrisOPā€¢13mo ago
no, I don't, I have it only build on that app it's filtered down
Brody
Brodyā€¢13mo ago
but whats your root directory set to in your service settings?
Harris
HarrisOPā€¢13mo ago
oh hmm
No description
No description
No description
Harris
HarrisOPā€¢13mo ago
there is a way to change dockerfile location though i believe
Brody
Brodyā€¢13mo ago
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 dockerfile
Harris
HarrisOPā€¢13mo ago
i see, it has to be at root?
Brody
Brodyā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
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?
Brody
Brodyā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
what do i know (not much), try it lol
Harris
HarrisOPā€¢13mo ago
i geninunely don't know either am just trying to piece things together SweatCat
Brody
Brodyā€¢13mo ago
cant hurt to try
Harris
HarrisOPā€¢13mo ago
this racks my brain though
No description
Harris
HarrisOPā€¢13mo ago
trying to merge these instructions from turborepo to bun
Brody
Brodyā€¢13mo ago
start with something simple like luna's dockerfile
Harris
HarrisOPā€¢13mo ago
i copied the one from bun's site and am trying to modify it to work with turborepo pruning
No description
Brody
Brodyā€¢13mo ago
copy in everything, you dont need to complicate things with multistage just get it working first, dont worry about anything fancy
luna
lunaā€¢13mo ago
itā€™s better to have a working dockerfile thatā€™s huge than a non working smaller one. šŸ˜…
Harris
HarrisOPā€¢13mo ago
i have an idea FrogAlert
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
praying to the ai gods
luna
lunaā€¢13mo ago
lol
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
poggies does nixpacks handle port stuff? just realized I never had to map my port 3001 to port 80 or anything on nixpacks
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
ah i see so nixpacks just does 80 am guessing
Brody
Brodyā€¢13mo ago
nothing to do with nixpacks, railway makes a random PORT variable available, then maps that to 443 externally
Harris
HarrisOPā€¢13mo ago
how do I handle that in my dockerfile? with the expose
luna
lunaā€¢13mo ago
you donā€™t need todo anything in the dockerfile. in your app just listen on the process.env.PORT
Harris
HarrisOPā€¢13mo ago
oh so I don't need to expose anything in the dockerfile?
Harris
HarrisOPā€¢13mo ago
No description
Brody
Brodyā€¢13mo ago
yep, what Luna said, no need for expose
Harris
HarrisOPā€¢13mo ago
interesting, i don't get how that works but I'll trust y'all. blobthumbsup like doesn't the container block networking unless you expose?
luna
lunaā€¢13mo ago
nope
Harris
HarrisOPā€¢13mo ago
oh, that seems, bad?
luna
lunaā€¢13mo ago
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.
Brody
Brodyā€¢13mo ago
plus the containers are isolated
luna
lunaā€¢13mo ago
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.
Harris
HarrisOPā€¢13mo ago
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
luna
lunaā€¢13mo ago
yeah i dont list any of mine.
luna
lunaā€¢13mo ago
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.
Brody
Brodyā€¢13mo ago
that depends though, if you need a variable during build then you do have to bring it in with the ARG keyword.
luna
lunaā€¢13mo ago
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ā€¦
luna
lunaā€¢13mo ago
good point yeah thereā€™s also build vs runtime envs
Harris
HarrisOPā€¢13mo ago
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)
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /usr/src/app

# install turbo and prune the monorepo
FROM base AS builder
RUN bun install -g turbo
COPY . .
RUN turbo prune ws_server --docker

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY --from=builder ./out/json/ /temp/dev/
COPY --from=builder ./out/bun.lockb /temp/dev/bun.lockb
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY --from=builder ./out/json/ /temp/prod/
COPY --from=builder ./out/bun.lockb /temp/prod/bun.lockb
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM install AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY --from=builder ./out/full .

# build the app
ENV NODE_ENV=production
RUN turbo run build --filter=ws_server

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/. .

# run the app
USER bun
ENTRYPOINT [ "turbo", "run", "start", "--filter=ws_server" ]
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /usr/src/app

# install turbo and prune the monorepo
FROM base AS builder
RUN bun install -g turbo
COPY . .
RUN turbo prune ws_server --docker

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY --from=builder ./out/json/ /temp/dev/
COPY --from=builder ./out/bun.lockb /temp/dev/bun.lockb
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY --from=builder ./out/json/ /temp/prod/
COPY --from=builder ./out/bun.lockb /temp/prod/bun.lockb
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM install AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY --from=builder ./out/full .

# build the app
ENV NODE_ENV=production
RUN turbo run build --filter=ws_server

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/. .

# run the app
USER bun
ENTRYPOINT [ "turbo", "run", "start", "--filter=ws_server" ]
is where I'm at so far
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
currently debugging
luna
lunaā€¢13mo ago
avoid using global install use npx instead or bunx
Harris
HarrisOPā€¢13mo ago
will do! why?
luna
lunaā€¢13mo ago
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 šŸ˜…
Harris
HarrisOPā€¢13mo ago
No description
luna
lunaā€¢13mo ago
and then you've got versions clashing, etc.
Harris
HarrisOPā€¢13mo ago
so this instead?
Harris
HarrisOPā€¢13mo ago
so many things to learn poggers
No description
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
oh welp did all this work for nothing bezoslaugh
Brody
Brodyā€¢13mo ago
haha told you to not worry about all that and just get it working first
Harris
HarrisOPā€¢13mo ago
you were pepehands my attempt to be optimal i was sub-optimal
Brody
Brodyā€¢13mo ago
KISS
Harris
HarrisOPā€¢13mo ago
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 pain nixpacks use docker in the middle (like could you see a dockerfile it generates?)
Brody
Brodyā€¢13mo ago
nixpacks does generate a dockerfile
Harris
HarrisOPā€¢13mo ago
hmm i might just give up for now and go back to just using nixpacks and manually updating bun whenever it does seems easier
Brody
Brodyā€¢13mo ago
just write the simple dockerfile like ive been saying
Harris
HarrisOPā€¢13mo ago
working on itā„¢ļø currently undoing all the other stuff and trying to keep it simple need to also figure out the openssl issue
Brody
Brodyā€¢13mo ago
there shouldnt be an openssl issue when using the bun image?
Harris
HarrisOPā€¢13mo ago
oh nice
Brody
Brodyā€¢13mo ago
famous last words
Harris
HarrisOPā€¢13mo ago
in every programmer there are two wolves the "i want it optimal" wolf and the "i want it working" wolf
Brody
Brodyā€¢13mo ago
thats fine as long as the "i want it working" wolf gets to drive first
Harris
HarrisOPā€¢13mo ago
yes, am currently trying to figure out environment variables now because prisma needs them to Monke
Harris
HarrisOPā€¢13mo ago
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /usr/src/app

FROM base AS install
COPY . .
RUN bun install --frozen-lockfile

FROM install AS builder
ENV NODE_ENV=production
RUN bunx turbo run build --filter=ws_server

# run the app
FROM builder AS release
USER bun
ENTRYPOINT [ "bunx", "turbo", "run", "start", "--filter=ws_server" ]
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /usr/src/app

FROM base AS install
COPY . .
RUN bun install --frozen-lockfile

FROM install AS builder
ENV NODE_ENV=production
RUN bunx turbo run build --filter=ws_server

# run the app
FROM builder AS release
USER bun
ENTRYPOINT [ "bunx", "turbo", "run", "start", "--filter=ws_server" ]
No description
Harris
HarrisOPā€¢13mo ago
ty wait it's so cursed hmm maybe I don't do bun install from root level
Brody
Brodyā€¢13mo ago
very much no
Harris
HarrisOPā€¢13mo ago
?
Brody
Brodyā€¢13mo ago
dont mess around with multiple stages
Harris
HarrisOPā€¢13mo ago
ah, i copied those from the bun example, will remove them
Brody
Brodyā€¢13mo ago
you arent copying files between the stages, so it wont work
Harris
HarrisOPā€¢13mo ago
does nixpacks just put a ton of ARG commands in it's dockerfile then?
Brody
Brodyā€¢13mo ago
yes lol
ARG CGO_ENABLED NIXPACKS_METADATA RAILWAY_DEPLOYMENT_ID RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID RAILWAY_SERVICE_ID RAILWAY_SERVICE_UTILITIES_URL RAILWAY_SNAPSHOT_ID RAILWAY_STATIC_URL
ENV CGO_ENABLED=$CGO_ENABLED NIXPACKS_METADATA=$NIXPACKS_METADATA RAILWAY_DEPLOYMENT_ID=$RAILWAY_DEPLOYMENT_ID RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID=$RAILWAY_ENVIRONMENT_ID RAILWAY_GIT_AUTHOR=$RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH=$RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE=$RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA=$RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME=$RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER=$RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID=$RAILWAY_PROJECT_ID RAILWAY_SERVICE_ID=$RAILWAY_SERVICE_ID RAILWAY_SERVICE_UTILITIES_URL=$RAILWAY_SERVICE_UTILITIES_URL RAILWAY_SNAPSHOT_ID=$RAILWAY_SNAPSHOT_ID RAILWAY_STATIC_URL=$RAILWAY_STATIC_URL
ARG CGO_ENABLED NIXPACKS_METADATA RAILWAY_DEPLOYMENT_ID RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID RAILWAY_SERVICE_ID RAILWAY_SERVICE_UTILITIES_URL RAILWAY_SNAPSHOT_ID RAILWAY_STATIC_URL
ENV CGO_ENABLED=$CGO_ENABLED NIXPACKS_METADATA=$NIXPACKS_METADATA RAILWAY_DEPLOYMENT_ID=$RAILWAY_DEPLOYMENT_ID RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID=$RAILWAY_ENVIRONMENT_ID RAILWAY_GIT_AUTHOR=$RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH=$RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE=$RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA=$RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME=$RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER=$RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID=$RAILWAY_PROJECT_ID RAILWAY_SERVICE_ID=$RAILWAY_SERVICE_ID RAILWAY_SERVICE_UTILITIES_URL=$RAILWAY_SERVICE_UTILITIES_URL RAILWAY_SNAPSHOT_ID=$RAILWAY_SNAPSHOT_ID RAILWAY_STATIC_URL=$RAILWAY_STATIC_URL
Harris
HarrisOPā€¢13mo ago
šŸ‘€
Brody
Brodyā€¢13mo ago
dont do this yourself tho
Harris
HarrisOPā€¢13mo ago
No description
Brody
Brodyā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
you dont need to assign an arg to an env
Harris
HarrisOPā€¢13mo ago
why does nixpacks do it?
Brody
Brodyā€¢13mo ago
heck if i know, all i know is line 8 is not needed
Harris
HarrisOPā€¢13mo ago
thumbthumbsup good
Brody
Brodyā€¢13mo ago
why cd into ws_server? doesnt turbo have some kind of command to install deps for a specfic app?
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
right so isnt there a way to install packages for a specfic app, without cd
Harris
HarrisOPā€¢13mo ago
i don't think there's a turbo wrapped command for installing deps?
Brody
Brodyā€¢13mo ago
you cd into that folder and then never cd back out
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
does bun have a way to install deps from a package in a subfolder? i think you should avoid using cd
luna
lunaā€¢13mo ago
huh? just add cd to the end that's how half my production Dockerfiles are written šŸ˜…
Brody
Brodyā€¢13mo ago
idk just sounds yucky to me, cd'ing around
luna
lunaā€¢13mo ago
šŸ¤·ā€ā™€ļø most production code is held together with duct tape it is what it is
Harris
HarrisOPā€¢13mo ago
right now i still can't figure out what environment variable is causing it not to install lmao
No description
Harris
HarrisOPā€¢13mo ago
i think my .env might be being copied in the copy . . command? guessing i should add it to dockerignore? am testing locally rn
Harris
HarrisOPā€¢13mo ago
oh wait i already have it
No description
Harris
HarrisOPā€¢13mo ago
hmm
Brody
Brodyā€¢13mo ago
this do be odd how many service variables you got?
luna
lunaā€¢13mo ago
where is the error being thrown..? šŸ¤” any chance you can do this locally instead of railway?
Harris
HarrisOPā€¢13mo ago
i am testing locally
luna
lunaā€¢13mo ago
i test all mine locally before pushing if you run those exact commands locally OUTSIDE of docker..?
Harris
HarrisOPā€¢13mo ago
ah haven't tried that yet, but I think bun would use my .env
luna
lunaā€¢13mo ago
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 happy
Harris
HarrisOPā€¢13mo ago
No description
Brody
Brodyā€¢13mo ago
a decent amount
Harris
HarrisOPā€¢13mo ago
cool
No description
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
railway up time
Harris
HarrisOPā€¢13mo ago
github push šŸ˜Ž i test on main
Brody
Brodyā€¢13mo ago
haha nice
Harris
HarrisOPā€¢13mo ago
i was wrong
Harris
HarrisOPā€¢13mo ago
No description
Brody
Brodyā€¢13mo ago
bring all the variables into the dockerfile lol
Harris
HarrisOPā€¢13mo ago
well so, i tested all the commands locally and they work now it's only on railway do i get prisma undefined issue
Harris
HarrisOPā€¢13mo ago
No description
Brody
Brodyā€¢13mo ago
such a useful error message
Harris
HarrisOPā€¢13mo ago
I tried replacing the command with bun prisma generate, but that didn't help
Brody
Brodyā€¢13mo ago
your database url variable, is it a public or private url?
Harris
HarrisOPā€¢13mo ago
public in that it has user/pass in it
Brody
Brodyā€¢13mo ago
all database urls do lol
Harris
HarrisOPā€¢13mo ago
ah still public i'm guessing? it's on neon db
Brody
Brodyā€¢13mo ago
ah then yeah definitely public
Harris
HarrisOPā€¢13mo ago
and i don't limit it
Brody
Brodyā€¢13mo ago
print all the variables with printenv?
Harris
HarrisOPā€¢13mo ago
in the dockerfile?
Brody
Brodyā€¢13mo ago
yeah
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
this is indeed weird
Harris
HarrisOPā€¢13mo ago
i removed the turbo build command and the build completes without error 773MB image
Brody
Brodyā€¢13mo ago
does the app run tho haha
Harris
HarrisOPā€¢13mo ago
time to find out
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
no no it does not ahhh need to do bunx turbo
Harris
HarrisOPā€¢13mo ago
No description
Brody
Brodyā€¢13mo ago
you should set the start command in the dockerfile instead
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
i think I do?
Brody
Brodyā€¢13mo ago
with CMD
Harris
HarrisOPā€¢13mo ago
oh
Brody
Brodyā€¢13mo ago
and in shell format aka not in an array
Harris
HarrisOPā€¢13mo ago
worry
No description
Harris
HarrisOPā€¢13mo ago
User bun killing me here i think
Brody
Brodyā€¢13mo ago
oh yes, don't switch users
Harris
HarrisOPā€¢13mo ago
what's the difference?
Brody
Brodyā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
why did nixpacks kinda work tho
Harris
HarrisOPā€¢13mo ago
this is what i'm confused about
Brody
Brodyā€¢13mo ago
we may never know
Harris
HarrisOPā€¢13mo ago
how can I get the dockerfile that nixpacks creates via railway?
Brody
Brodyā€¢13mo ago
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
angelo
angeloā€¢13mo ago
You can run Nicpacks locally and produce an image!
angelo
angeloā€¢13mo ago
Getting full context
Brody
Brodyā€¢13mo ago
šŸ¤£
angelo
angeloā€¢13mo ago
Hello from Twitter
Harris
HarrisOPā€¢13mo ago
Angelo saw me declare defeat on twitter and wanted to help blobcat
Brody
Brodyā€¢13mo ago
youre in better hands now
Harris
HarrisOPā€¢13mo ago
you and luna were pretty amazing hands though so thank you again
angelo
angeloā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
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)
No description
Harris
HarrisOPā€¢13mo ago
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 sweaty occurs in my turbo run build --filter=ws_server command
angelo
angeloā€¢13mo ago
Can you share to me: - folder structure - package file - dockerfile TURBO
Harris
HarrisOPā€¢13mo ago
want read access to my repo?
angelo
angeloā€¢13mo ago
okay, this narrows down some styff
Harris
HarrisOPā€¢13mo ago
might be easier than copying here
angelo
angeloā€¢13mo ago
Why the hell not: [email protected] Grabbing my laptop one sec
Harris
HarrisOPā€¢13mo ago
https://github.com/StarlightLabsCo/bonfire/invitations omg, ty i thought u were already on it
angelo
angeloā€¢13mo ago
Angelo voice I'm in I doomscroll Twitter for the holidays
Harris
HarrisOPā€¢13mo ago
i pushed the bare minimal dockerfile on a new branch called... wait for it.. salute
angelo
angeloā€¢13mo ago
I presume the dockerfile branch is the one I should be working in?
Harris
HarrisOPā€¢13mo ago
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 madbun also doing turborepo prune in dockerfile before I learned that it doesn't support bun yet so switched to doing bare minimum dockerfile first
angelo
angeloā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
they go zooooom
angelo
angeloā€¢13mo ago
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 sec
Harris
HarrisOPā€¢13mo ago
Ohhh ā¤ļø
angelo
angeloā€¢13mo ago
Project ID on Railway? I can add myself to a staging env (and will send credits) to test railway up
Harris
HarrisOPā€¢13mo ago
Sorry got pulled away Back now Thank you so much for looking into this
Harris
HarrisOPā€¢13mo ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Harris
HarrisOPā€¢13mo ago
what was the issue?
angelo
angeloā€¢13mo ago
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?
Harris
HarrisOPā€¢13mo ago
go for it! šŸ«”
angelo
angeloā€¢13mo ago
I ask because I don't wanna fail our audit of the SoC2 audit Security requirement
Harris
HarrisOPā€¢13mo ago
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
Brody
Brodyā€¢13mo ago
if that really is the problem or one of the problems, remember what I said šŸ™‚
angelo
angeloā€¢13mo ago
The settings is wrong šŸ˜ When you have a Dockerfile, the docker build context reigns supreme
Harris
HarrisOPā€¢13mo ago
ohhh wait
Harris
HarrisOPā€¢13mo ago
locally i was doing -f
No description
angelo
angeloā€¢13mo ago
(this is why we are hiring ;-;) It applies only to nixpacks, so for monorepo Dockerfile, you want to host the file at root
Brody
Brodyā€¢13mo ago
hehe that's that I suggested, I'm smort
angelo
angeloā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
u were right salute
angelo
angeloā€¢13mo ago
this is a classic rake skating exercise only advanced rake skaters can solve this (possible)
Brody
Brodyā€¢13mo ago
what are your parents feeding you
Harris
HarrisOPā€¢13mo ago
No description
angelo
angeloā€¢13mo ago
No description
angelo
angeloā€¢13mo ago
YES favorite meme
Harris
HarrisOPā€¢13mo ago
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 ???
angelo
angeloā€¢13mo ago
Yes
Harris
HarrisOPā€¢13mo ago
and it's a bun thing specifically?
angelo
angeloā€¢13mo ago
no (yes) Okay, now resolving the railway specifc error, > [6/6] RUN bunx prisma generate: 1.508 Error: undefined this is US ugh
Harris
HarrisOPā€¢13mo ago
OH wait, so this was the bun specific one? or just something else what's the tell?
angelo
angeloā€¢13mo ago
(one sec, gf called) back
#13 exporting to image
#13 exporting layers
#13 exporting layers 3.0s done
#13 writing image sha256:6acc7097e8e4364ccfa17193710d55e35f3ea0a48d911b990ad0e92162ed91b6 done
#13 DONE 3.0s
#13 exporting to image
#13 exporting layers
#13 exporting layers 3.0s done
#13 writing image sha256:6acc7097e8e4364ccfa17193710d55e35f3ea0a48d911b990ad0e92162ed91b6 done
#13 DONE 3.0s
Okay- so bunx prisma generate needed Node in the container ;-; Okay- now testing deploy
Brody
Brodyā€¢13mo ago
welp that explains why nixpacks worked?
angelo
angeloā€¢13mo ago
Yep- JR's multi-lang detection resolution is goated as the kids say
angelo
angeloā€¢13mo ago
No description
angelo
angeloā€¢13mo ago
found a bug, we don't allow an up deploy if watch paths are enabled...
Harris
HarrisOPā€¢13mo ago
Monke ohh i see
angelo
angeloā€¢13mo ago
this is insanely non-obvious had to GH issue splunkel to find the solution to that
Harris
HarrisOPā€¢13mo ago
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
angelo
angeloā€¢13mo ago
Jerred and I will be having a... talk
Harris
HarrisOPā€¢13mo ago
madbun
angelo
angeloā€¢13mo ago
The start command is invalid.

Start command: `turbo run start --filter=ws_server`
The start command is invalid.

Start command: `turbo run start --filter=ws_server`
Will tell Railway to use the container start, one sec
Brody
Brodyā€¢13mo ago
question, why is that invalid anyway
angelo
angeloā€¢13mo ago
I dunno
Brody
Brodyā€¢13mo ago
kekw
angelo
angeloā€¢13mo ago
You can accuse the Railway team for many shortcomings, honesty isn't one of them
Brody
Brodyā€¢13mo ago
very true
angelo
angeloā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
is bunx prisma generate usually just a shim to npx? is that why it had an issue
angelo
angeloā€¢13mo ago
I think so
angelo
angeloā€¢13mo ago
No description
angelo
angeloā€¢13mo ago
turbo fun... lemme see here, will bang it to shape
Harris
HarrisOPā€¢13mo ago
pepehands is supposed to cover that one
angelo
angeloā€¢13mo ago
wait yea ez fix, one sec CMD [ "bunx", "turbo", "run", "start", "--filter=ws_server" ] is this the intended command?
Harris
HarrisOPā€¢13mo ago
i believeso not super familar with cmd syntax
angelo
angeloā€¢13mo ago
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.
angelo
angeloā€¢13mo ago
live can you throw some requests there?
Harris
HarrisOPā€¢13mo ago
lemme spin up a local project and change the backend url not project but just running it lol
angelo
angeloā€¢13mo ago
Harris
HarrisOPā€¢13mo ago
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?
angelo
angeloā€¢13mo ago
Yes
FROM oven/bun:1 as base
WORKDIR /usr/src/app

RUN apt update \
&& apt install -y curl

# Install nodejs using n
ARG NODE_VERSION=18
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
&& bash n $NODE_VERSION \
&& rm n \
&& npm install -g n

COPY . .
ARG DATABASE_URL
ARG DIRECT_URL
RUN dir -s
RUN cd ./apps/ws_server && bun install --frozen-lockfile && cd /usr/src/app

ENV NODE_ENV=production
# RUN bunx prisma generate
RUN bunx turbo run build --filter=ws_server

CMD bunx turbo run start --filter=ws_server
FROM oven/bun:1 as base
WORKDIR /usr/src/app

RUN apt update \
&& apt install -y curl

# Install nodejs using n
ARG NODE_VERSION=18
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
&& bash n $NODE_VERSION \
&& rm n \
&& npm install -g n

COPY . .
ARG DATABASE_URL
ARG DIRECT_URL
RUN dir -s
RUN cd ./apps/ws_server && bun install --frozen-lockfile && cd /usr/src/app

ENV NODE_ENV=production
# RUN bunx prisma generate
RUN bunx turbo run build --filter=ws_server

CMD bunx turbo run start --filter=ws_server
angelo
angeloā€¢13mo ago
My file tree:
No description
Harris
HarrisOPā€¢13mo ago
you're the best ty
angelo
angeloā€¢13mo ago
no u for picking Railway Happy Belated Thanksgiving!
Harris
HarrisOPā€¢13mo ago
you as well!
angelo
angeloā€¢13mo ago
also massive thanks to @luna and @Brody- they deserve the credit as well šŸ¤—
Harris
HarrisOPā€¢13mo ago
@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?
angelo
angeloā€¢13mo ago
Yep
luna
lunaā€¢13mo ago
i dont know the answer but i am curious especially based on https://twitter.com/leeerob/status/1727380301054349441
angelo
angeloā€¢13mo ago
You are hosting this on vercel? I don't think it should interfere
Harris
HarrisOPā€¢13mo ago
ohlord
angelo
angeloā€¢13mo ago
This is a revamp of Zeit Now if you remember back when Vercel were called Zeit
Harris
HarrisOPā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
ah
Brody
Brodyā€¢13mo ago
we will see that world with railway
angelo
angeloā€¢13mo ago
Johnny is cool person! (Zeet)
Harris
HarrisOPā€¢13mo ago
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
angelo
angeloā€¢13mo ago
so, if you can for me, can you trigger a vercel PR deployment? I don't think it should interfere
Harris
HarrisOPā€¢13mo ago
just did no issue
Harris
HarrisOPā€¢13mo ago
No description
angelo
angeloā€¢13mo ago
vercel looks for a turbo.json at the root so that seems to be fine
Harris
HarrisOPā€¢13mo ago
but 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
angelo
angeloā€¢13mo ago
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
Harris
HarrisOPā€¢13mo ago
gotcha so that solves the issue completely then poggers
angelo
angeloā€¢13mo ago
pog
Harris
HarrisOPā€¢13mo ago
although ocd me really wants to put them in subfolders sadblob
Brody
Brodyā€¢13mo ago
just give them nice names
Harris
HarrisOPā€¢13mo ago
I'll name Dockerfile.Tim and salute
Harris
HarrisOPā€¢13mo ago
No description
Harris
HarrisOPā€¢13mo ago
No description
Want results from more Discord servers?
Add your server