When am I try to reuse PNPM store, I getting 'cross-device link not permitted' in Docker build on GitLab CI
Asked Answered
P

0

7

I'm trying to reuse pnpm store with docker buildkit inline cache. It is working fine, when I'm doing local build but on gitlab ci it throw cross-device link not permitted error.

Error

...
#12 2.257  WARN  EXDEV: cross-device link not permitted, link '/root/.local/share/pnpm/store/v3/files/68/31d9850g49ag49cc526af456f4a19a0f76eb85a79b6b311f09df7dd62a2a4d0f5c83de4eb5c6648f8bff155c82edce40a4e6c61cvb71127e1cb93c3cb8ab0f' -> '/usr/app/node_modules/.pnpm/[email protected]/node_modules/_tmp_1_58b64396e8cfdcdv7a5b403e046a9203/LICENSE'
#12 2.257 Falling back to copying packages from store
#12 2.316  WARN  EXDEV: cross-device link not permitted, link '/root/.local/share/pnpm/store/v3/files/6b/416bd4d9c57a078ff0a54c56f32039bb01aa5b3a3f07bev60d8ecc6eaa830db5ac4192943d693baaa1fc09b7891306db00055f3805ee6cc02ff353d8477f5c' -> '/usr/app/node_modules/.pnpm/[email protected]/node_modules/_tmp_1_ae5f485297e737f5f3943671v7fd357d/.github/dependabot.yml'
#12 2.316 Falling back to copying packages from store
#12 2.741  WARN  EXDEV: cross-device link not permitted, link '/root/.local/share/pnpm/store/v3/files/ba/80df1a5d3176e962200ca4d1304c02617df7ba747736cada94d29e94883f71f4b3231ee0a02c33886ba454215f65ff4320e0cc49f22fb431383f88c483cb9e' -> '/usr/app/node_modules/.pnpm/[email protected]/node_modules/_tmp_1_c0e9a25e81dg99592va167a1v86c382s/package.json'
#12 2.741 Falling back to copying packages from store
#12 3.174 Progress: resolved 624, reused 0, downloaded 101, added 96
#12 4.175 Progress: resolved 624, reused 0, downloaded 184, added 179
#12 5.175 Progress: resolved 624, reused 0, downloaded 229, added 220
...

Dockerfile

FROM node:16-alpine as builder

WORKDIR /usr/app

COPY package.json .babelrc jsconfig.json esbuild.config.js pnpm-lock.yaml ./
COPY src ./src

RUN npm install -g pnpm

RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
    pnpm fetch

RUN pnpm install --recursive --offline --frozen-lockfile --prod --unsafe-perm && \
    pnpm run build

FROM node:16-alpine

WORKDIR /usr/app

COPY package.json esbuild.config.js ./
COPY --from=builder /usr/app/dist dist

EXPOSE 3030

CMD node dist/bundle.js

GitLab CI

build:
  image: docker:stable
  services:
    - docker:dind
  stage: build
  script:
  - export DOCKER_BUILDKIT=1
  - docker build --cache-from $CONTAINER_IMAGE -t $CONTAINER_IMAGE --build-arg BUILDKIT_INLINE_CACHE=1 .
Parthenopaeus answered 19/8, 2022 at 4:23 Comment(5)
I am getting this warning even on my local Mac M1, but even with this warning packages are getting reused. And only newly added packages are getting downloaded. #16 1.245  WARN  EXDEV: cross-device link not permitted, link '/pnpm/store/v3/files/29/844c3773154ee8b2e579050c77793e74261da427b77cf5ea7b010de3f167d60d9aaec8165b25a41065477508fb3be56c47a6ce8c0e61e2a297d6b4664398c5' -> '/app/node_modules/.pnp... #16 10.53 Progress: resolved 341, reused 340, downloaded 1, added 341 #16 10.66 #16 11.53 Progress: resolved 341, reused 340, downloaded 1, added 341, done #16 DONE 11.9sKadiyevka
Do you have the same behavior on Gitlab CI?Kadiyevka
Is you gitlab ci configured, so that each run gets started on the same host and that you are allowed to use caching on host machine?Kadiyevka
No, acutely 0 reuse. In gitlab ci, they spin up new container for each build.Parthenopaeus
I have the exact same issue but using Github actions, where you ever able to overcome it?Lachman

© 2022 - 2024 — McMap. All rights reserved.