R
Railway6mo ago
~/qudo

pnpm cacheid & Docker

Is there a way to make this cache ID dynamic per environment? Noticed this thread that said it's not possible. But does this mean I need a separate Dockerfile for each env where the only difference is the cache ID? thanks https://help.railway.app/questions/cache-mount-id-is-not-prefixed-with-cach-fcaed775
Railway Help Station
Cache mount ID is not prefixed with cache key
I'm getting the error above with this Dockerfile: ```dockerfile ARG NODE_VERSION=20.11.1 Alpine Image FROM node:${NODE_VERSION}-alpine AS alpine RUN echo '1' RUN apk update RUN apk add --no-cache libc6-compat Setup PNPM and Turbo on the Alpine Image FROM alpine as base RUN echo '2' RUN npm install pnpm turbo --global --no-cache RUN pnp...
25 Replies
Percy
Percy6mo ago
Project ID: N/A
Brody
Brody6mo ago
the cache id is the service id, so the id should be the same across multiple environments
~/qudo
~/qudoOP6mo ago
oh! ok no issue then, must have been comparing wrong urls thanks
Brody
Brody6mo ago
https://railway.app/project/<project id>/service/<service id> thats the format of the url, if the same service in both the environments have different ids then something was misconfigured
~/qudo
~/qudoOP6mo ago
do you know if there's any way to alias this --mount arg? its a lot to prifix every pnpm command with but its what works. RUN --mount=type=cache,id=s/370985b8-9fc8-495b-a3ed-352a36eb803d-/root/.local/share/pnpm/store/v3,target=/root/.local/share/pnpm/store/v3 pnpm i
Brody
Brody6mo ago
nope, no shortcuts there
~/qudo
~/qudoOP6mo ago
dang..might make a lil ui then that you put in a service id + turbo project name and get a dockerfile lol
Brody
Brody6mo ago
the v2 builder might be able to build just as fast without a cache mount
~/qudo
~/qudoOP6mo ago
i am kinda ignorant in that area, does that mean i could run just pnpm i?
Brody
Brody6mo ago
correct try it, enable the v2 builder and don't have any cache mounts
~/qudo
~/qudoOP6mo ago
pushed up a build, lets see. is there a way to see how long older builds too?
~/qudo
~/qudoOP6mo ago
its nice how on vercel they show the duration next to each so you can quickly tell if its growing after a change or something
No description
Brody
Brody6mo ago
the time is printed in the logs for the legacy builder, but for the new builder just look at the first timestamp and the last timestamp before the image is pushed
~/qudo
~/qudoOP6mo ago
this kinda thing
No description
Brody
Brody6mo ago
yeah that would be useful oh wait, railway does have that, enable the new deployment UI in your feature flags though it currently doesn't record the build time for the v2 builder and will read something like 00.00, but that will be fixed
~/qudo
~/qudoOP6mo ago
ok cool, i'll check it out. also, after removing the cache id, it seems it was a little faster, so no loss at least, awesome.
Brody
Brody6mo ago
you are on the v2 builder?
~/qudo
~/qudoOP6mo ago
yep
Brody
Brody6mo ago
awesome and the v2 builder is a part of an environments private network too!
~/qudo
~/qudoOP6mo ago
i should be able to make the app name in turbo build --filter app-name dynamic right? if so, and i don't need the cache id, that makes a pretty clean reusable dockerfile for the monorepo I guess just make it a railway var and ezgg huh
Brody
Brody6mo ago
yeah you can interpolate variables into RUN commands yeah
~/qudo
~/qudoOP6mo ago
would be cool if your defined variable args were additionally passed in as a list. i have a case where sveltekit wants a .env to exist for some reason. in my case, it would be handy to be able to loop over the variables and write out. or maybe i have an unusual pattern
No description
Brody
Brody6mo ago
what's stopping you from looping over the output of printenv from slicing it by newlines
~/qudo
~/qudoOP6mo ago
i discovered that later. i didn't think they existed in the env without defining as build args.
Brody
Brody6mo ago
that's only true for build time, they would be there during runtime regardless
Want results from more Discord servers?
Add your server