My Docker file builds locally but continually fails on deployment to Railway
nicholasboyce
HOBBYOP

2 years 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 PNPM_HOME="/pnpm"

ENV PATH="$PNPM_HOME:$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 NODE_ENV=production

COPY ./server ./server

COPY --from=prod-deps /server/node_modules /server/node_modules

COPY --from=build /server/dist /server/dist

WORKDIR /server

CMD [ "pnpm", "start" ]

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

3 Replies

nicholasboyce
HOBBYOP

2 years 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.


kelkunvictor
PRO

2 years ago

Hello, i have exactly same problem.


nicholasboyce
HOBBYOP

2 years 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.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...