Can't get cache for NodeJS builds. "node_modules/: no matching files"

Hello,

I have my CI set up like that:

image: docker:latest
services:
  - docker:dind

variables:
  DOCKER_DRIVER: overlay

cache:
  untracked: true
  key: "$CI_PROJECT_ID"
  paths:
  - node_modules/
  - app/node_modules/

stages:
  - package

docker-build:
  stage: package
  variables:
DOCKER_DRIVER: overlay
  only:
- master
  script:
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  - docker build -t registry.gitlab.com/mwurbanowicz/***/api .
  - docker push registry.gitlab.com/mwurbanowicz/***/api

This is my Dockerfile:

FROM node:alpine
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
EXPOSE 3000
CMD [ "npm", "start" ]

I can’t get cache for node_modules at all.
All the time getting mssage that no files have been found.

Anyone can tell me what is wrong? It’s pretty straight forward so I have no idea why it’s not working.

Can anybody help?

I can’t find a solution to this problem myself. It appears that CI cache is not working even in the latest 10.2 GitLab. I see many people reporting the problem, but not finding a solid fix.

It’s still and issue, and in my setup it fails randomly, so i have to monitor my builds… :frowning:

Issue still seems persistent or did I miss something? Currently I have 1. a pretty extended build/deploy time and 2. have to use only a single job for install, build and deployment.