R
Railway9mo ago
devour

Cache mount ID is not prefixed with cache key

I'm getting the error above with this 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 pnpm config set store-dir /root/.local/share/pnpm/store/v3

# Prune Projects
FROM base AS pruner
ARG PROJECT=api

RUN echo '3'

WORKDIR /app
COPY . .
RUN turbo prune --scope=${PROJECT} --docker

# Build Project
FROM base AS builder
ARG PROJECT=api
ARG RAILWAY_SERVICE_ID

RUN echo ${RAILWAY_SERVICE_ID}

WORKDIR /app

# Copy lockfile and package.json's
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=pruner /app/out/json/ .

# Install Dependencies
RUN --mount=type=cache,id=s/${RAILWAY_SERVICE_ID}-/root/.local/share/pnpm/store/v3,target=/root/.local/share/pnpm/store/v3 pnpm install --frozen-lockfile

# Copy Source Code
COPY --from=pruner /app/out/full/ .

RUN turbo build --filter=${PROJECT}
RUN --mount=type=cache,id=s/${RAILWAY_SERVICE_ID}-/root/.local/share/pnpm/store/v3,target=/root/.local/share/pnpm/store/v3 pnpm prune --prod --no-optional
RUN rm -rf ./**/*/src

# Final Image
FROM alpine AS runner
ARG PROJECT=api

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs

WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app .
WORKDIR /app/apps/${PROJECT}

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

EXPOSE ${PORT}

CMD node dist/server.js
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 pnpm config set store-dir /root/.local/share/pnpm/store/v3

# Prune Projects
FROM base AS pruner
ARG PROJECT=api

RUN echo '3'

WORKDIR /app
COPY . .
RUN turbo prune --scope=${PROJECT} --docker

# Build Project
FROM base AS builder
ARG PROJECT=api
ARG RAILWAY_SERVICE_ID

RUN echo ${RAILWAY_SERVICE_ID}

WORKDIR /app

# Copy lockfile and package.json's
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=pruner /app/out/json/ .

# Install Dependencies
RUN --mount=type=cache,id=s/${RAILWAY_SERVICE_ID}-/root/.local/share/pnpm/store/v3,target=/root/.local/share/pnpm/store/v3 pnpm install --frozen-lockfile

# Copy Source Code
COPY --from=pruner /app/out/full/ .

RUN turbo build --filter=${PROJECT}
RUN --mount=type=cache,id=s/${RAILWAY_SERVICE_ID}-/root/.local/share/pnpm/store/v3,target=/root/.local/share/pnpm/store/v3 pnpm prune --prod --no-optional
RUN rm -rf ./**/*/src

# Final Image
FROM alpine AS runner
ARG PROJECT=api

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs

WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app .
WORKDIR /app/apps/${PROJECT}

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

EXPOSE ${PORT}

CMD node dist/server.js
I am using Turborepo and the Dockerfile is located in /apps/api/Dockerfile. What am I doing wrong here?
No description
No description
Solution:
you can't use ${RAILWAY_SERVICE_ID} the service id would need to be hardcoded
Jump to solution
5 Replies
Percy
Percy9mo ago
Project ID: 48848408-a9ee-4094-ba13-e65c1e6a1646
devour
devourOP9mo ago
48848408-a9ee-4094-ba13-e65c1e6a1646
Solution
Brody
Brody9mo ago
you can't use ${RAILWAY_SERVICE_ID} the service id would need to be hardcoded
devour
devourOP9mo ago
oh let me try that yep that was it, thanks!
Duchess
Duchess9mo ago
New reply sent from Help Station thread:
Safari hides the full URL and makes me look for the <service id> for ages, >_<
You're seeing this because this thread has been automatically linked to the Help Station thread. New reply sent from Help Station thread:
You can also copy the Service ID from the command pallet when you have a project open, cmd / ctrl + k -> Copy Service ID.
You're seeing this because this thread has been automatically linked to the Help Station thread.
Want results from more Discord servers?
Add your server