23 days ago
deployment ID 1acb3b80-04e3-47bf-bef6-2555841fa6ba. Include that the builder stage generates files but they never reach the runner stage despite the COPY --from=builder command being in the Dockerfile.
4 Replies
23 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 23 days ago
22 days ago
Service: web in poetic-adventure project
Deployment ID: 1acb3b80-04e3-47bf-bef6-2555841fa6ba
Issue: Docker multi-stage builder COPY not receiving files from builder stage due to buildkit layer caching; final image digest unchanged across builds despite builder generating new files
scottpatterson2
Service: web in poetic-adventure project Deployment ID: 1acb3b80-04e3-47bf-bef6-2555841fa6ba Issue: Docker multi-stage builder COPY not receiving files from builder stage due to buildkit layer caching; final image digest unchanged across builds despite builder generating new files
22 days ago
can you paste your dockerfile? mainly need to see the COPY --from=builder line and the builder stage's WORKDIR. also do the build logs show the builder steps actually running, or do they all say "cached"?
22 days ago
packages/api/Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY tsconfig.json ./
COPY src ./src
RUN npm run build
FROM node:20-alpine AS runner
WORKDIR /app
COPY package*.json ./
RUN npm install --omit=dev && npm cache clean --force
COPY --from=builder /app/dist ./dist
RUN addgroup -S haul && adduser -S haul -G haul
USER haul
EXPOSE 3000
ENV NODE_ENV=production
ENV PORT=3000
CMD ["node", "dist/index.js"]
note: we are trying to break the build cache
The logs say that the steps are running
22 days ago
i think its the build context not the cache. your dockerfile is in packages/api but COPY src ./src copies from wherever the build context is. if the service's root directory in railway settings isnt set to packages/api, the builder keeps grabbing the wrong src, compiles the same code every time, and the digest never changes even tho the steps run.
go to service settings → root directory → set it to packages/api and redeploy.
if thats already set, add RUN ls -la /app/dist at the end of the builder stage and paste what the build log shows, also check your tsconfig outDir is actually dist