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
Project ID:
N/A
the cache id is the service id, so the id should be the same across multiple environments
oh! ok no issue then, must have been comparing wrong urls thanks
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 misconfigureddo 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
nope, no shortcuts there
dang..might make a lil ui then that you put in a service id + turbo project name and get a dockerfile lol
the v2 builder might be able to build just as fast without a cache mount
i am kinda ignorant in that area, does that mean i could run just
pnpm i
?correct
try it, enable the v2 builder and don't have any cache mounts
pushed up a build, lets see. is there a way to see how long older builds too?
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
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
this kinda thing
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
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.
you are on the v2 builder?
yep
awesome
and the v2 builder is a part of an environments private network too!
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 huhyeah you can interpolate variables into RUN commands yeah
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 patternwhat's stopping you from looping over the output of printenv from slicing it by newlines
i discovered that later. i didn't think they existed in the env without defining as build args.
that's only true for build time, they would be there during runtime regardless