a year ago
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
I am using Turborepo and the Dockerfile is located in /apps/api/Dockerfile
.
What am I doing wrong here?
2 Replies
a year ago
48848408-a9ee-4094-ba13-e65c1e6a1646
a year ago
you can't use ${RAILWAY_SERVICE_ID}
the service id would need to be hardcoded
Status changed to Solved railway[bot] • about 1 year ago
a year ago
oh let me try that
a year ago
yep that was it, thanks!
fre2d0mPRO
a year ago
Safari hides the full URL and makes me look for the 'service id' for ages, >_<
a year ago
You can also copy the Service ID from the command pallet when you have a project open, cmd / ctrl + k
-> Copy Service ID.