diff --git a/tehriehlbudget-backend/Dockerfile b/tehriehlbudget-backend/Dockerfile index 987cfa1..167e045 100644 --- a/tehriehlbudget-backend/Dockerfile +++ b/tehriehlbudget-backend/Dockerfile @@ -5,6 +5,13 @@ FROM node:${NODE_VERSION}-alpine AS deps RUN apk add --no-cache libc6-compat openssl RUN corepack enable && corepack prepare pnpm@9 --activate WORKDIR /repo +# Force a hoisted (flat) node_modules layout for the image. The default pnpm +# isolated layout puts dependencies inside node_modules/.pnpm/@/ +# which makes `prisma generate`'s output (node_modules/.prisma/client/) live +# in a path that doesn't survive a multi-stage COPY. Hoisted gives us +# predictable /repo/node_modules/{@prisma,.prisma}/ paths. Local dev is +# unaffected — this .npmrc only exists inside the build context. +RUN echo "node-linker=hoisted" > /repo/.npmrc COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./ COPY tehriehlbudget-backend/package.json tehriehlbudget-backend/ COPY tehriehlbudget-frontend/package.json tehriehlbudget-frontend/ @@ -30,11 +37,12 @@ ENV NODE_ENV=production COPY --from=build --chown=nodeapp:nodeapp /repo/tehriehlbudget-backend/dist ./dist COPY --from=build --chown=nodeapp:nodeapp /repo/tehriehlbudget-backend/prisma ./prisma COPY --from=build --chown=nodeapp:nodeapp /repo/tehriehlbudget-backend/package.json ./package.json -COPY --from=prod-deps --chown=nodeapp:nodeapp /repo/tehriehlbudget-backend/node_modules ./node_modules -# Overlay generated Prisma client from the build stage (the prod-deps stage -# pruned the `prisma` CLI devDep, which removes the client during install). -COPY --from=build --chown=nodeapp:nodeapp /repo/tehriehlbudget-backend/node_modules/.prisma ./node_modules/.prisma -COPY --from=build --chown=nodeapp:nodeapp /repo/tehriehlbudget-backend/node_modules/@prisma ./node_modules/@prisma +# With hoisted linker, all deps live at the workspace-root node_modules. +COPY --from=prod-deps --chown=nodeapp:nodeapp /repo/node_modules ./node_modules +# Overlay the generated Prisma client from the build stage. The prod-deps +# stage doesn't have the `prisma` CLI (devDep) so it can't generate. +COPY --from=build --chown=nodeapp:nodeapp /repo/node_modules/.prisma ./node_modules/.prisma +COPY --from=build --chown=nodeapp:nodeapp /repo/node_modules/@prisma ./node_modules/@prisma USER nodeapp EXPOSE 3000 ENTRYPOINT ["/sbin/tini", "--"]