Do you want to request a feature or report a bug?
What is the current behavior?
We usually structure our Dockerfiles to take advantage of the Docker cache mechanism, so we first copy
yarn.lock, then run
yarn --pure-lockfile and then copy the rest of the package.
Doing so, the dependencies, that change less often than the package source code, can be cached by Docker, and we can often avoid to have Yarn run on each build.
With Yarn workspaces, you can’t run
yarn if you have just the
package.json and the
yarn.lock file, because it will complain about the missing workspace packages.
If the current behavior is a bug, please provide the steps to reproduce.
Have a Dockerfile like this:
FROM node:9-alpine WORKDIR /app COPY package.json . COPY yarn.lock . RUN yarn --pure-lockfile COPY . . RUN yarn test
What is the expected behavior?
There should be a way to tell Yarn to install all the dependencies and defer the packages linking to a later step once the whole source code is copied.
Doing so we can reduce the repetitive task to just the packages linking, and cache the installation/fetching of the dependencies.