Dockerizing Nodejs dependencies for Gitlab CI

I’m using Gitlab CI in order to implement CI for my Node.js app. I’m already using artifacts and sharing the dependencies between jobs, however, I would like to make it faster. Every time a pipeline starts, it installs the dependencies during the first job and I’m thinking to prevent this by having all dependencies in a Docker image and pass that image to test & production stages. However, I have been unable to do so. Apparently Gitlab doesn’t run the code inside my image’s WORKDIR.

Following is my Dockerfile:

FROM node:6.13-alpine
WORKDIR /home/app
COPY package.json .
RUN npm install
CMD [“sh”]

And following is my gitlab-ci.yml:

  image: azarboon/dependencies-test
  stage: test
     — pwd
     — npm run test

Looking at logs, pwd results in /builds/anderson-martin/lambda-test, which is different from the defined WORKDIR and also installed dependencies are not found. Do you have any recommendation for me how can I Dockerize my dependencies and speed up the build stage?