But why the following work:
FROM node:10-alpine as node
WORKDIR /app
COPY package*.json ./
RUN npm install
ADD . .
RUN npm run build
The last line npm run build
will reuse the node dependencies downloaded in the step npm install
.
The only difference is that the node dependencies will be saved in the current directory while gradle dependencies will be put outside the current directory.