Build COPY is not working
scottpatterson2
HOBBYOP

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.

$10 Bounty

4 Replies

Railway
BOT

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


scottpatterson2
HOBBYOP

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

manuproject
HOBBY

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"?


scottpatterson2
HOBBYOP

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


manuproject
HOBBY

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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...