I have all this npm stuff in my Dockerfile and it is taking a long time to build my docker image. How can I speed this up, and ideally cache the results? Nothing is changing, so I wouldn't expect this to take such a long time (about 20 seconds now).
FROM python:3.6-alpine
# python stuff
COPY requirements.txt /app/requirements.txt
RUN pip3 install --upgrade pip
RUN pip3 install -r /app/requirements.txt
# npm stuff
RUN apk add --update nodejs-npm
RUN npm init -y
RUN npm i webpack webpack-cli --save-dev
RUN npm i @babel/core babel-loader @babel/preset-env @babel/preset-react babel-plugin-transform-class-properties --save-dev
RUN npm i react react-dom prop-types --save
RUN npm i react-bootstrap bootstrap
RUN npm i weak-key --save
I did try this solution using the COPY package.json
but babel
and webpack
did not seem to like that (and it did not work).
NOTE: I need to use python:3.6-alpine
as this is an existing Django application that is integrating React.js