Cache mount ID is not prefixed with cache key

danielroman11
HOBBY

a year ago

Railways is giving me this error even when I hardcode the service ID as the documentation says:

--mount=type=cache,id=s/-,target=

But even this the application is not passing the build process

FROM node:20-slim AS base
ENV PNPMHOME="/pnpm" ENV PATH="$PNPMHOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

FROM base AS prod-deps
RUN --mount=type=cache,id=s/example-example-example-84f8-9f9dc8662531-/pnpm/store,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=s/example-example-example-9f9dc8662531-/pnpm/store,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/nodemodules /app/nodemodules
COPY --from=build /app/dist /app/dist

ARG PORT=3000
ENV PORT=${PORT}
ENV NODE_ENV=production

EXPOSE ${PORT}
CMD [ "pnpm", "start" ]

View Deploy details

> ⓘ Deployment information is only viewable by Project members and Railway admins.

7 Replies

a year ago

For what its worth, IDs are not sensitive, at all.

Please attach your Dockerfile, with the correct service ID.


danielroman11
HOBBY

a year ago

This is the Dockerfile with the correct ID, I test a lot of times and this one is working, but It cant resolve the store dir, so the dependencies cannot be retrieve.

FROM node:20-slim AS base
COPY . /app
WORKDIR /app

Instalar PNPM solo si no está instalado previamente

RUN if ! command -v pnpm &> /dev/null; then npm i -g pnpm; fi

Configurar el directorio de almacenamiento de PNPM

RUN pnpm config set store-dir ~/.pnpm-store

FROM base AS prod-deps
RUN --mount=type=cache,id=s/c3c868f7-49e7-49da-9efb-f2c04a4a58d5-/.pnpm-store,target=/.pnpm-store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=s/c3c868f7-49e7-49da-9efb-f2c04a4a58d5-/.pnpm-store,target=/.pnpm-store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/nodemodules /app/nodemodules
COPY --from=build /app/dist /app/dist

ARG PORT=3000
ENV PORT=${PORT}
ENV NODE_ENV=production

EXPOSE ${PORT}
CMD [ "pnpm", "start" ]


a year ago

Please attach your Dockerfile, as a file attachment.


danielroman11
HOBBY

a year ago

Its impossible it says unsopported type file:
`
FROM node:20-slim AS base
COPY . /app
WORKDIR /app
COPY . .

RUN if ! command -v pnpm &> /dev/null; then npm i -g pnpm; fi

RUN pnpm config set store-dir ~/.pnpm-store

FROM base AS prod-deps
RUN --mount=type=cache,id=s/c3c868f7-49e7-49da-9efb-f2c04a4a58d5-/pnpm/store,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=s/c3c868f7-49e7-49da-9efb-f2c04a4a58d5-/pnpm/store,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/nodemodules /app/nodemodules
COPY --from=build /app/dist /app/dist

WORKDIR /app

ARG PORT=3000
ENV PORT=${PORT}
ENV NODE_ENV=production

EXPOSE ${PORT}
CMD [ "pnpm", "start" ]

`


a year ago

Simply changing the extension to .txt works.


danielroman11
HOBBY

a year ago

Unsupported filetype: says


a year ago

It works

Attachments


Cache mount ID is not prefixed with cache key - Railway Help Station