10 months ago
Error: Cache mount ID is not prefixed with cache key
This is all the information I'm getting from the build logs.
Another thread said I had to hardcode the service ID so I tried that and still nothing. What am I doing wrong? I followed pnpm's docs on working with Docker.
FROM node:20-slim AS base
ENV PNPMHOME="/pnpm" ENV PATH="$PNPMHOME:$PATH"
RUN corepack enable
FROM base AS build
COPY . .
WORKDIR /frontend
RUN --mount=type=cache,id=s/61157178-b645-40e6-855c-da8d7d21d802-/pnpm/store,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
FROM base AS prod-deps
COPY . .
WORKDIR /server
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base AS server
ENV NODEENV=production COPY ./server ./server COPY --from=prod-deps /server/nodemodules /server/node_modules
COPY --from=build /server/dist /server/dist
WORKDIR /server
CMD [ "pnpm", "start" ]
ⓘ Deployment information is only viewable by project members and Railway employees.
3 Replies
10 months ago
Well, I was missing the hardcoded service id in the prod deps stage. In case anyone else does land here working with Docker and PNPM, I just copied over the "target" from what was provided in the pnpm docs for working with Docker ('/pnpm/store') and thankfully that worked. The Railway docs suggest going to the Nixpacks source code but that didn't really help me.
10 months ago
Hello, i have exactly same problem.
10 months ago
Hey did you ever get it working? The only issue in my Dockerfile in the text above is that I hadn't hardcoded the Railway service ID in the second pnpm install command I did.